### Install and Setup JS UI Skeleton Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/js-ui.md Install the js-ui-skeleton, copy its assets, and install Node.js dependencies. ```bash composer require koriym/js-ui-skeleton 1.x-dev cp -r vendor/koriym/js-ui-skeleton/ui . cp -r vendor/koriym/js-ui-skeleton/package.json . npm install ``` -------------------------------- ### Install and Initialize BEAR.Sunday Project Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/setup.md Use Composer to create a new project skeleton and then use the 'malt' tool to initialize, install dependencies, create the project structure, and start the development server. Source the environment variables for the current shell session. ```bash composer create-project bear/skeleton my-app cd my-app malt init && malt install && malt create && malt start source <(malt env) ``` -------------------------------- ### Install HaloModule Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/html.md Example of installing the HaloModule within a Dev context module. This enables the Halo UI for development purposes. ```php class DevModule extends AbstractModule { protected function configure(): void { $this->install(new HaloModule($this)); } } ``` -------------------------------- ### API Doc Service Setup Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/hypermedia-api.md Example of setting up an API documentation service by extending BEAR\ApiDoc\ApiDoc. ```php install(new FastlyModule()) $this->install(new AkamaiModule()) ``` -------------------------------- ### Install and Use CLI via Homebrew Tap Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/cli.md Install the CLI tool from a Homebrew tap and verify the installation by checking the version. This demonstrates the end-user installation process. ```bash $ brew tap your-vendor/greet # homebrew- prefix can be omitted $ brew install your-vendor/greet # Ready to use immediately $ greet --version greet version 0.1.0 ``` -------------------------------- ### ResourceObject Implementation Example Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/coding-guide.md Demonstrates the structure of a ResourceObject with GET and POST methods, including annotations for caching, embedding, and linking. Use this for defining API resources. ```php code = Code::CREATED; return $this; } } ``` -------------------------------- ### Install Ray.DbalModule Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/database.dbal.md Install the Ray.DbalModule package using composer. ```bash composer require ray/dbal-module ``` -------------------------------- ### Install MySQL 8.0 Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/setup.md Installs and starts MySQL 8.0 on macOS using Homebrew, or on Ubuntu/Debian and CentOS/RHEL using their respective package managers. ```bash # macOS (Homebrew) brew install mysql@8.0 brew services start mysql@8.0 ``` ```bash # Ubuntu/Debian sudo apt install mysql-server-8.0 sudo systemctl start mysql ``` ```bash # CentOS/RHEL sudo dnf install mysql-server sudo systemctl start mysqld ``` -------------------------------- ### Example HTTP GET Request and Response Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial2.md Demonstrates a simple GET request to the root endpoint and the expected HAL+JSON response. The HTTP access log records the request details and the server's response, including headers and body. ```http curl -s -i 'http://127.0.0.1:8080/' HTTP/1.1 200 OK Host: 127.0.0.1:8080 Date: Fri, 21 May 2021 22:41:02 GMT Connection: close X-Powered-By: PHP/8.0.6 Content-Type: application/hal+json { "_links": { "self": { "href": "/index" }, "goTickets": { "href": "/tickets" } } } ``` -------------------------------- ### Module Installation Priority Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/module.md Demonstrates module installation priority. Modules installed first take priority. Use `override()` to give a later module priority. ```php $this->install(new Foo1Module); $this->install(new Foo2Module); ``` ```php $this->install(new Foo1Module); $this->override(new Foo2Module); ``` -------------------------------- ### Run Composer Setup Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/coding-guide.md Execute this command to initialize the database and check libraries during application setup. It may prompt for manual configuration like .env settings. ```bash composer setup ``` -------------------------------- ### Install BEAR.Async Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/async.md Use Composer to install the BEAR.Async package. This is the primary step to enable parallel resource execution. ```bash composer require bear/async ``` -------------------------------- ### Install CLI Tool via Homebrew Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial3.md Users can easily install and use your CLI tool by tapping your repository and installing the package. ```bash brew tap yourusername/tap brew install greet greet -n "User" -l en ``` -------------------------------- ### Install xhprof Extension Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/html.md Instructions for installing the xhprof PECL extension for performance profiling. Remember to add the extension to your php.ini. ```bash pecl install xhprof // Also add 'extension=xhprof.so' to your php.ini file ``` -------------------------------- ### Install Modules with Composer Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial2.md Use Composer to install the necessary modules for your project. This command installs the identity-value and media-query modules. ```bash composer require ray/identity-value-module ray/media-query -w ``` -------------------------------- ### Install malt with Homebrew Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/setup.md Installs malt and its dependencies using Homebrew. Ensure Homebrew is installed and taps are added before running. ```bash brew tap shivammathur/php brew tap shivammathur/extensions brew tap koriym/malt brew install malt ``` -------------------------------- ### Compile and Install Swoole from Source Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/server.md Compile and install the Swoole PHP extension from its source code. This method provides more control over the build process. ```bash git clone https://github.com/swoole/swoole-src.git && \ cd swoole-src && \ phpize && \ ./configure && \ make && make install ``` -------------------------------- ### Console Output Example Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/quick-start.md Example of the expected output when running a page resource from the console. ```text 200 OK Content-Type: application/hal+json { "greeting": "Hello World", "_links": { "self": { "href": "/hello?name=World" } } } ``` -------------------------------- ### Start Built-in Web Server Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial.md Start the PHP built-in web server to serve the BEAR.Sunday application. This is useful for local development and testing. ```bash php -S 127.0.0.1:8080 bin/app.php ``` -------------------------------- ### Install BEAR.Security Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/security.md Install the BEAR.Security package using Composer. This command is for development environments. ```bash composer require --dev bear/security ``` -------------------------------- ### Install Jekyll and Bundler Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/README.md Install the necessary Ruby gems for running the documentation server locally. Requires Ruby 3.2.3. ```bash gem install jekyll bundler ``` ```bash bundle install ``` -------------------------------- ### Install Aura.SqlQuery Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/databasev1.md Install the Aura.SqlQuery module with the application module, specifying the database type. ```php $this->install(new AuraSqlQueryModule('mysql')); // pgsql, sqlite, or sqlsrv ``` -------------------------------- ### Start Development Server Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/psr7.md Launch the built-in PHP development server. This command starts a server on localhost port 8080, serving files from the public directory. ```bash php -S 127.0.0.1:8080 -t public ``` -------------------------------- ### Install Modules in AppModule Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/module.md Demonstrates how to install additional modules and basic modules within the root AppModule. Use this to set up core application components like database and templating engines. ```php class AppModule extends AbstractAppModule { /** * {@inheritdoc} */ protected function configure() { // ... // install additional modules $this->install(new AuraSqlModule('mysql:host=localhost;dbname=test', 'username', 'password'); $this->install(new TwigModule)); // install basic module $this->install(new PackageModule)); } } ``` -------------------------------- ### Start PHP Development Server Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial.md Start the built-in PHP development server to test the web application. Access the application via a web browser to view the HTML output. ```bash php -S 127.0.0.1:8080 public/index.php ``` -------------------------------- ### Install xhprof for Profiling Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/ja/html.md Provides commands to install the xhprof extension for PHP profiling on macOS, Windows, and Linux. ```bash pecl install xhprof # php.iniファイルに'extension=xhprof.so'を追加 ``` ```bash # macOS brew install graphviz # Windows # graphvizのWebサイトからインストーラをダウンロードしてインストール # Linux (Ubuntu) sudo apt-get install graphviz ``` -------------------------------- ### Install BEAR.Swoole Package Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/server.md Install the BEAR.Swoole package using Composer. This integrates Swoole with the BEAR.Sunday framework. ```bash composer require bear/swoole ``` -------------------------------- ### Configure Project Environment Variables Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/setup.md Example .env file for configuring database (MySQL and SQLite examples) and cache (Redis, Memcached) connection details. Ensure DB_DSN is correctly set for your chosen database. ```dotenv # MySQL DB_HOST=127.0.0.1 DB_PORT=3306 DB_NAME=myapp DB_USER=root DB_PASS= DB_DSN=mysql:host=127.0.0.1;port=3306;dbname=myapp # SQLite (switching example) # DB_DSN=sqlite:var/db.sqlite3 # Redis REDIS_HOST=127.0.0.1:6379 # Memcached MEMCACHED_HOST=127.0.0.1:11211 ``` -------------------------------- ### Enable Content Negotiation via Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/content-negotiation.md Install the AcceptModule to enable content negotiation on a per-resource basis. This module should be installed within your application's configure method. ```php protected function configure() { // ... $available = $appDir . '/var/locale/available.php'; $this->install(new AcceptModule($available)); } ``` -------------------------------- ### Install Imported Application with ImportAppModule Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/import.md Install other applications using `ImportAppModule`, specifying the hostname, application namespace, and context for the import. ```php +use BEAR\Package\Module\ImportAppModule; +use BEAR\Package\Module\Import\ImportApp; class AppModule extends AbstractAppModule { protected function configure(): void { // ... $this->install(new ImportAppModule([ new ImportApp('foo', 'MyVendor\Weekday', 'prod-app') ])); $this->install(new PackageModule()); } } ``` -------------------------------- ### Setup Script for DB Creation and Migration Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial2.md Edit bin/setup.php to automate database creation, seeding, and migration processes. ```php load(dirname(__DIR__)); chdir(dirname(__DIR__)); passthru('rm -rf var/tmp/*'); passthru('chmod 775 var/tmp'); passthru('chmod 775 var/log'); // db $pdo = new \PDO('mysql:host=' . getenv('TKT_DB_HOST'), getenv('TKT_DB_USER'), getenv('TKT_DB_PASS')); $pdo->exec('CREATE DATABASE IF NOT EXISTS ' . getenv('TKT_DB_NAME')); $pdo->exec('DROP DATABASE IF EXISTS ' . getenv('TKT_DB_NAME') . '_test'); $pdo->exec('CREATE DATABASE ' . getenv('TKT_DB_NAME') . '_test'); passthru('./vendor/bin/phinx migrate -c var/phinx/phinx.php -e development'); passthru('./vendor/bin/phinx migrate -c var/phinx/phinx.php -e test'); ``` -------------------------------- ### API Doc Demo Setup Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/hypermedia-api.md Commands to set up and run the Polidog.Todo demo for API documentation. ```bash git clone https://github.com/koriym/Polidog.Todo.git cd Polidog.Todo/ composer install composer setup composer doc ``` -------------------------------- ### GET Resource Object Example Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/resource.md Defines a resource object for handling GET requests. It calculates the sum of two integer parameters passed via GET and sets the result in the response body. ```php class Index extends ResourceObject { public $code = 200; public $headers = []; public function onGet(int $a, int $b): static { $this->body = [ 'sum' => $a + $b // $_GET['a'] + $_GET['b'] ] ; return $this; } } ``` -------------------------------- ### Example Response with Content Negotiation Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/content-negotiation.md An example HTTP response demonstrating content negotiation, including the Vary header and the negotiated content type. ```http HTTP/1.1 200 OK Host: 127.0.0.1:8080 Date: Fri, 11 Aug 2017 08:32:33 +0200 Connection: close X-Powered-By: PHP/7.1.4 Vary: Accept, Accept-Language content-type: application/hal+json { "greeting": "Hello BEAR.Sunday", "_links": { "self": { "href": "/index" } } } ``` -------------------------------- ### Create Development Configuration Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/js-ui.md Set up a PHP configuration file for the 'hello' application, defining the state to be passed to the UI. ```php 'World']; $metas = []; return [$app, $state, $metas]; ``` -------------------------------- ### Install Local Formula Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/cli.md Install a development version of the CLI tool using a local Homebrew formula file. This is useful for testing. ```bash $ brew install --formula ./var/homebrew/greet.rb ``` -------------------------------- ### Install Request Header Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/router.md Install the RequestHeaderModule to enable Aura.Router to match requests based on headers. This is typically done during application setup. ```php $this->install(new RequestHeaderModule()); ``` -------------------------------- ### Web Router Convention Example Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/router.md Example of a resource class for the web router. A request to 'page://self/index' will be handled by the onGet method of this class. ```php namespace MyVendor\MyProject\Resource\Page; // page://self/index class Index extends ResourceObject { public function onGet(): static // GET request { } } ``` -------------------------------- ### Manage Development Server with malt Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/setup.md Use the 'malt' tool to start the development server with either Apache or Nginx, check the status of services, start or stop all services, or stop individual services. ```bash # Choose Apache / Nginx and start malt start apache # http://127.0.0.1:8080 malt start nginx # http://127.0.0.1:80 # Check services malt status # Start/stop all services malt start malt stop # Individual stop malt stop apache malt stop nginx ``` -------------------------------- ### Start API Server Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial.md Launch the BEAR.Sunday API server using PHP's built-in web server. This command starts the server on `127.0.0.1:8081`. ```bash php -S 127.0.0.1:8081 bin/app.php ``` -------------------------------- ### Run the UI Application Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/js-ui.md Start the demo UI application using npm. Configuration for the application can be found in the ui/dev/config/ directory. ```bash npm run ui ``` -------------------------------- ### Install DbalModule in Application Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/database.dbal.md Install the DbalModule in your application's module configuration to enable database abstraction. This example uses a PDO SQLite in-memory database. ```php use BEAR\Package\AbstractAppModule; use Ray\DbalModule\DbalModule; class AppModule extends AbstractAppModule { protected function configure() { // ... $this->install(new DbalModule('driver=pdo_sqlite&memory=true')); } } ``` -------------------------------- ### Setup Qiq Template Directory Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/html-qiq.md Copy the default Qiq template directory from the vendor package to your project's var directory. ```bash cd /path/to/project cp -r vendor/bear/qiq-module/var/qiq var ``` -------------------------------- ### Set Up Database Migrations with Phinx Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/setup.md Install Phinx using Composer, initialize it in your project, create a new migration file, and then run the migrations to update your database schema. ```bash composer require --dev robmorgan/phinx ./vendor/bin/phinx init ./vendor/bin/phinx create MyMigration ./vendor/bin/phinx migrate ``` -------------------------------- ### GET Resource via curl Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial.md Access a resource using `curl` after starting the API server. This demonstrates retrieving data from the running API. ```bash curl -i 'http://127.0.0.1:8081/todos?id=1' ``` -------------------------------- ### Create Test Context Boot File Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial.md Set up the `bin/test.php` file for cache-enabled tests. This file bootstraps the application for CLI execution. ```php install(new AsyncSwooleModule()); $this->install(new PdoPoolEnvModule('PDO_DSN', 'PDO_USER', 'PDO_PASSWORD')); } } ``` -------------------------------- ### Configure HTTP Test Client in PHP Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial2.md Inherit the Workflow test class and set the HttpResource client in the setUp method to test the REST API over HTTP. The HttpResource connects to a built-in server started with a specified bootstrap script. ```php class WorkflowTest extends Workflow { protected function setUp(): void { $this->resource = new HttpResource('127.0.0.1:8080', __DIR__ . '/index.php', __DIR__ . '/log/workflow.log'); } } ``` -------------------------------- ### Run Demo Application Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/form.md Execute the demo application from the Ray.WebFormModule repository using the PHP built-in web server. ```bash php -S docs/demo/1.csrf/web.php ``` -------------------------------- ### SQL for Input Object Parameter Expansion Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/database.media.md Example SQL file demonstrating how parameters from an Input object are used in an INSERT statement. The placeholders match the property names of the Input class. ```sql -- user_create.sql INSERT INTO users (name, email, age) VALUES (:name, :email, :age); ``` -------------------------------- ### Install Mobile Twig Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/html-twig-v2.md Install `MobileTwigModule` to enable template selection for mobile devices. This module should be installed alongside the base `TwigModule`. ```php class HtmlModule extends AbstractModule { protected function configure() { $this->install(new TwigModule); $this->install(new MobileTwigModule); } } ``` -------------------------------- ### Set up Homebrew Tap Repository Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial3.md Clone your Homebrew tap repository, copy the formula, commit, and push to distribute your CLI tool. ```bash git clone https://github.com/yourusername/homebrew-tap.git cp var/homebrew/greet.rb homebrew-tap/greet.rb cd homebrew-tap git add greet.rb git commit -m "Add greet formula" git push ``` -------------------------------- ### Production Deployment with Docker Compose Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/server.md Use this command to start your production server environment. Ensure you are in the correct server directory (e.g., 'swoole') before executing. ```bash cd swoole # or roadrunner, frankenphp docker compose -f docker-compose.prod.yml up -d ``` -------------------------------- ### Install ApcSsrModule for Performance Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/js-ui.md Install ApcSsrModule to enable V8 snapshot caching in APCu for improved performance. Ensure the V8Js extension is installed. ```php $bundleSrcBasePath = dirname(__DIR__, 2) . '/var/www/build'; $this->install(new ApcSsrModule($bundleSrcBasePath)); ``` -------------------------------- ### Install Swoole Extension via PECL Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/server.md Install the Swoole PHP extension using PECL. Ensure you have the necessary build tools and PHP development headers installed. ```bash pecl install swoole ``` -------------------------------- ### Async Entrypoint for PHP-FPM/Apache (ext-parallel) Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/async.md Use this entrypoint for applications running on PHP-FPM or Apache to enable parallel execution of #[Embed] resources via ext-parallel. Ensure 'bear/async' is installed. ```php install(new AttributeModule()); ``` -------------------------------- ### Serve Locally with Docker Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/CLAUDE.md Starts a local development server using Docker. This is an alternative to the direct local serve script. ```bash # Serve with Docker ./bin/serve_docker.sh ``` -------------------------------- ### Install Aura.Sql Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/databasev1.md Install the Ray.AuraSqlModule via composer to enable Aura.Sql integration. ```bash composer require ray/aura-sql-module ``` -------------------------------- ### Install WebFormModule in Application Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/form.md Install the WebFormModule within your application's AbstractModule. ```php use Ray\Di\AbstractModule; use Ray\WebFormModule\WebFormModule; class AppModule extends AbstractModule { protected function configure() { $this->install(new WebFormModule()); } } ``` -------------------------------- ### Display CLI Help Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/cli.md Use the --help option to display available commands and their descriptions. This is useful for understanding the CLI's capabilities and options. ```bash $ greet --help Say hello in multiple languages Usage: greet [options] Options: --name, -n Name to greet (required) --lang, -l Language (en, ja, fr, es) (default: en) --help, -h Show this help message --version, -v Show version information --format Output format (text|json) (default: text) ``` -------------------------------- ### DataLoader Solution Example Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/resource_link.md Demonstrates how DataLoader batches multiple resource requests into a single efficient query, significantly reducing the total number of database queries. ```text [Query 1] SELECT * FROM author WHERE id = 1 [Query 2] SELECT * FROM post WHERE author_id = 1 [Query 3] SELECT * FROM meta WHERE post_id IN (10, 11, 12) ← Batched! Total: 3 queries (constant regardless of data size) ``` -------------------------------- ### Get Tickets Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial2.md Retrieves a list of all tickets. This endpoint is accessible via a GET request. ```APIDOC ## GET /tickets ### Description Retrieves a list of all tickets. ### Method GET ### Endpoint /tickets ### Response #### Success Response (200) - **tickets** (array) - A list of ticket objects. ``` -------------------------------- ### Run Swoole Server Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/server.md Start the Swoole server using the PHP command-line interface. The server will output its listening address and port. ```bash php bin/swoole.php ``` -------------------------------- ### Install Twig Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/html-twig-v1.md Install the Twig module using Composer to enable HTML representation. ```bash composer require madapaja/twig-module ^1.0 ``` -------------------------------- ### Install PHP Dependencies for RoadRunner Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/server.md Install the necessary RoadRunner HTTP and PSR-7 packages using Composer. ```bash composer require spiral/roadrunner-http nyholm/psr7 ``` -------------------------------- ### Install BEAR.Sunday Skeleton Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/quick-start.md Use Composer to create a new BEAR.Sunday project. Specify VENDOR and PACKAGE for custom names, otherwise, you will be prompted. ```bash VENDOR=MyVendor PACKAGE=MyProject composer create-project bear/skeleton my-project cd my-project ``` -------------------------------- ### Install Bear SSR Module Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/js-ui.md Install the bear/ssr-module using Composer to enable server-side rendering capabilities. ```bash composer require bear/ssr-module ``` -------------------------------- ### Create Vendor Directory and Skeleton App Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/aaas.md Set up a new vendor directory and create a BEAR.Sunday skeleton application within it using Composer. ```bash mkdir my-vendor cd my-vendor composer create-project bear/skeleton Acme.Blog ``` -------------------------------- ### PHP Configuration (php.ini) Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/setup-reference.md This is a comprehensive php.ini configuration file example. It covers error display, resource limits, performance optimizations like OPcache, session management, and internationalization settings. Uncomment Xdebug and XHProf sections for debugging and profiling. ```ini [PHP] ; Error display (development) display_errors = On display_startup_errors = On log_errors = On error_log = malt/logs/php_error.log error_reporting = E_ALL ; Resource limits memory_limit = 256M max_execution_time = 30 max_input_time = 60 upload_max_filesize = 64M post_max_size = 64M max_file_uploads = 20 ; Performance realpath_cache_size = 4M realpath_cache_ttl = 600 opcache.enable = 1 opcache.enable_cli = 0 opcache.memory_consumption = 128 opcache.interned_strings_buffer = 16 opcache.max_accelerated_files = 8000 # PHP 8.4 recommended value (increased) opcache.revalidate_freq = 2 opcache.save_comments = 1 opcache.enable_file_override = 0 ; Sessions session.save_handler = files session.save_path = malt/tmp/sessions session.gc_maxlifetime = 1440 session.cookie_httponly = 1 session.cookie_secure = 0 # For development (set to 1 for HTTPS) session.cookie_samesite = Lax # Strict recommended for production ; Japanese settings default_charset = UTF-8 mbstring.language = Japanese mbstring.internal_encoding = UTF-8 date.timezone = Asia/Tokyo [xdebug] ; Xdebug 3.x settings (usually commented out for performance) ; xdebug.mode = debug ; xdebug.start_with_request = yes ; xdebug.client_host = 127.0.0.1 ; xdebug.client_port = 9003 ; xdebug.log = malt/logs/xdebug.log [xhprof] ; XHProf settings (usually commented out for performance) ; xhprof.output_dir = malt/tmp/xhprof ``` -------------------------------- ### GET Resource via Console Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial.md Retrieve a created resource using the `bin/test.php` script with a GET request. ```bash php bin/test.php get '/todos?id=1' ``` -------------------------------- ### Generate API Documentation Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial2.md Run this command to generate API documentation for your project. The documentation will be output to the 'docs' folder. ```bash composer doc ``` -------------------------------- ### Install BEAR.Cli using Composer Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/cli.md Install the BEAR.Cli package using Composer to enable CLI command generation. ```bash composer require bear/cli ``` -------------------------------- ### Accessing Resources via CLI Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/cli.md This example shows how to access a BEAR.Sunday resource directly via the command line, demonstrating the output format. ```bash $ php bin/page.php '/greeting?name=World&lang=fr' { "greeting": "Bonjour, World", "lang": "fr" } ``` -------------------------------- ### Example of Customized SQL Log Output Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/database.media.md This is an example of how the SQL log will appear with the query ID included as a comment. ```sql -- App: todo_item.sql SELECT * FROM todo WHERE id = :id ``` -------------------------------- ### Installing PCOV for Faster Coverage Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/tutorial.md Install the PCOV extension via composer for potentially faster code coverage measurements. ```bash composer pcov ``` -------------------------------- ### Copy Configuration File Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/js-ui.md Create a new configuration file by copying an existing one, allowing for custom input settings. ```bash cp ui/dev/config/index.php ui/dev/config/myapp.php ``` -------------------------------- ### Install JsonSchemaModule Source: https://github.com/bearsunday/bearsunday.github.io/blob/master/manuals/1.0/en/validation.md Install `JsonSchemaModule` in your `AppModule` to enable JSON schema validation. Ensure the `var/json_schema` and `var/json_validate` directories exist. ```php use BEAR\Resource\Module\JsonSchemaModule; // Add this line use BEAR\Package\AbstractAppModule; class AppModule extends AbstractAppModule { protected function configure() { // ... $this->install( new JsonSchemaModule( $appDir . '/var/json_schema', $appDir . '/var/json_validate' ) ); // Add this line } } ```