### Drupal Multisite Configuration Directory Structure Examples Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt This snippet illustrates typical directory layouts for a Drupal multisite setup, showing how settings.php files are organized for the default site, a main domain, a subdomain, and a subdirectory site. It demonstrates how different site configurations are mapped to specific directories within the 'sites/' folder. ```Configuration sites/default/settings.php sites/example.com/settings.php sites/sub.example.com/settings.php sites/sub.example.com.site3/settings.php ``` -------------------------------- ### Run Composer Update to Install Mockery Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/getting_started/installation.rst Execute this command to install all defined development dependencies, including Mockery, after configuring your `composer.json`. This method ensures Mockery is installed for your development environment. Note that it will not be installed if `php composer.phar update --no-dev` is used. ```bash php composer.phar update ``` -------------------------------- ### Setup Development Environment for Slevomat Coding Standard Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/slevomat/coding-standard/README.md These shell commands outline the initial steps to set up a local development environment for the Slevomat Coding Standard repository. `composer install` fetches all necessary PHP dependencies, while `bin/phing` runs the project's build and setup tasks, preparing it for development. ```Shell composer install bin/phing ``` -------------------------------- ### Install Mockery Development Dependency via Composer Require Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/getting_started/installation.rst This command provides an alternative, direct way to install Mockery as a development dependency from the command line. The `--dev` flag ensures it's added to your `composer.json` and installed specifically for development purposes. It simplifies the process compared to manual `composer.json` editing. ```bash php composer.phar require --dev mockery/mockery ``` -------------------------------- ### Manually Creating and Permitting Drupal Files Directory Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt Commands to manually create the 'sites/default/files' directory and grant write permissions to it, as an alternative if automatic creation by the install script fails. ```Bash mkdir sites/default/files ``` ```Bash chmod a+w sites/default/files ``` -------------------------------- ### Creating and Permitting Drupal Settings File Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt Commands to copy the 'default.settings.php' template to 'settings.php' and temporarily grant write permissions for the web server to configure it during installation. Permissions should be reverted post-installation. ```Bash cp sites/default/default.settings.php sites/default/settings.php ``` ```Bash chmod a+w sites/default/settings.php ``` ```Bash chmod go-w sites/default/settings.php ``` -------------------------------- ### Example Composer Project with PHP_CodeSniffer Standards Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md This `composer.json` example demonstrates how to include the PHP_CodeSniffer Composer Installer Plugin along with various `phpcodesniffer-standard` packages as development dependencies. It sets up a project ready for automated code standard installation. ```json { "name": "example/project", "description": "Just an example project", "type": "project", "require": {}, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "*", "object-calisthenics/phpcs-calisthenics-rules": "*", "phpcompatibility/php-compatibility": "*", "wp-coding-standards/wpcs": "*" }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } } } ``` -------------------------------- ### Install Laminas Component Installer Per Project Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/laminas/laminas-component-installer/README.md This command installs the Laminas Component Installer as a project-specific Composer dependency, integrating it into the current project's Composer setup. ```bash composer require laminas/laminas-component-installer ``` -------------------------------- ### Phinx: Run Web Application Example Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/robmorgan/phinx/docs/en/commands.rst Start a local PHP web server to run the example Phinx web application. This allows interacting with Phinx via HTTP endpoints (e.g., `/migrate`, `/rollback`) for managing migration status and execution, though it's not suitable for production. ```bash $ php -S localhost:8000 vendor/robmorgan/phinx/app/web.php ``` -------------------------------- ### Securing Drupal Directories and Settings After Installation Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt Commands to manually revoke write permissions from 'settings.php' and the 'sites/default' directory after Drupal installation is complete, enhancing security. ```Bash chmod go-w sites/default/settings.php ``` ```Bash chmod go-w sites/default ``` -------------------------------- ### Drupal Standard Profile Translation File Location Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt The recommended directory path for placing translation (.po) files when installing Drupal with the Standard installation profile. ```Filesystem Path profiles/standard/translations/ ``` -------------------------------- ### Example Composer Project with PHP_CodeSniffer Standards Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md A composer.json example demonstrating a project that includes the installer plugin and several phpcodesniffer-standard packages (e.g., Object Calisthenics, PHPCompatibility, WordPress Coding Standards). It also includes the necessary allow-plugins configuration. ```json { "name": "example/project", "description": "Just an example project", "type": "project", "require": {}, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "*", "object-calisthenics/phpcs-calisthenics-rules": "*", "phpcompatibility/php-compatibility": "*", "wp-coding-standards/wpcs": "*" }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } } } ``` -------------------------------- ### Set Up Local Development for Mobile Detect Website Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/mobiledetect/mobiledetectlib/CONTRIBUTING.md This snippet outlines the steps to set up a local development environment for the Mobile Detect website. It involves checking out the `gh-pages` branch, installing `browser-sync` globally, and starting a local server for live reloading during development. ```Bash git checkout gh-pages npm install -g browser-sync browser-sync start --s . --f . --port 3000 --reload-debounce 1500 --no-ui ``` -------------------------------- ### Download Drupal Tarball using Wget Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt Command to download the specified Drupal version tarball from drupal.org using the `wget` utility on a Unix/Linux command line. ```Shell wget http://drupal.org/files/projects/drupal-x.y.tar.gz ``` -------------------------------- ### Install Psalm with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/installation.md Installs the Psalm static analysis tool as a development dependency using Composer. This is the recommended method for most PHP projects. ```bash composer require --dev vimeo/psalm ``` -------------------------------- ### Drupal Site-Specific Modules and Themes Directory Structure Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt This snippet demonstrates how to organize site-specific modules and themes within a Drupal multisite setup. It shows that custom themes and modules can be placed directly within a site's configuration directory (e.g., sites/sub.example.com/) to ensure they are only accessible to that particular site. ```Configuration sites/sub.example.com/ settings.php themes/custom_theme modules/custom_module ``` -------------------------------- ### Install and Enable Psalm Plugin Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/installation.md Installs a specific Psalm plugin as a development dependency using Composer, then enables it within Psalm's configuration. Plugins provide custom-tailored type information for various libraries. ```bash composer require --dev && vendor/bin/psalm-plugin enable ``` -------------------------------- ### Adjusting Write Permissions for Drupal Sites Directory Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt Commands to temporarily grant write permissions to the 'sites/default' directory, allowing the web server to create necessary files during Drupal installation. The permissions should be reverted after installation for security. ```Bash chmod a+w sites/default ``` ```Bash chmod go-w sites/default ``` -------------------------------- ### Example: Chained Mock Setup (PHP Mockery) Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/reference/expectations.rst An example demonstrating how to set up a mock object and its expectations in a single chained statement using Mockery. It shows creating a mock, defining a received method, setting its return value, and retrieving the mock object for further use. ```php $mock = \Mockery::mock('foo')->shouldReceive('foo')->andReturn(1)->getMock(); ``` -------------------------------- ### Install CakePHP via Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/cakephp/cakephp/README.md Use Composer to add the CakePHP framework to your project. For new applications, it's recommended to start with the official app skeleton. ```bash composer require cakephp/cakephp ``` -------------------------------- ### Define Mockery Development Dependency in Composer JSON Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/getting_started/installation.rst This JSON snippet shows how to declare Mockery as a development dependency within your project's `composer.json` file. It specifies `dev-master` as the version, but recommends using a stable tag for production. This configuration ensures Mockery is only installed during development. ```json { "require-dev": { "mockery/mockery": "dev-master" } } ``` -------------------------------- ### Install Laminas Component Installer Globally Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/laminas/laminas-component-installer/README.md This command installs the Laminas Component Installer as a global Composer utility, making it available for use across all projects on the system. ```bash composer global require laminas/laminas-component-installer ``` -------------------------------- ### Download and Install Drupal 7.x via Command Line Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/UPGRADE.txt These Bash commands facilitate downloading the Drupal 7.x archive, extracting its contents, and then copying the extracted files, including the .htaccess, into the specified Drupal installation directory. This method is suitable for servers with command-line access. ```Bash wget http://drupal.org/files/projects/drupal-x.y.tar.gz tar -zxvf drupal-x.y.tar.gz ``` ```Bash cp -R drupal-x.y/* drupal-x.y/.htaccess /path/to/your/installation ``` -------------------------------- ### Install Xdebug Handler via Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/composer/xdebug-handler/README.md Instructions on how to install the `composer/xdebug-handler` library using Composer, which is the recommended way to add it to your project. ```bash $ composer require composer/xdebug-handler ``` -------------------------------- ### Basic Phinx Migration Setup in PHPUnit setUp Method Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/robmorgan/phinx/docs/en/commands.rst This PHP code shows a basic 'setUp' method for a PHPUnit test case that runs Phinx migrations. It initializes 'PhinxApplication', disables auto-exit, and executes the 'migrate' command using 'StringInput' and 'NullOutput' to prepare the database for tests. ```php public function setUp () { $app = new PhinxApplication(); $app->setAutoExit(false); $app->run(new StringInput('migrate'), new NullOutput()); } ``` -------------------------------- ### Creating and Permitting Custom Drupal Uploads Directory Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt Commands to create a new directory for Drupal file uploads and grant write permissions to it, useful when changing the default file system storage path. ```Bash mkdir uploads ``` ```Bash chmod a+w uploads ``` -------------------------------- ### Extract Drupal Tarball using Tar Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt Command to extract the contents of the downloaded Drupal tarball (`.tar.gz`) into a new directory using the `tar` utility. ```Shell tar -zxvf drupal-x.y.tar.gz ``` -------------------------------- ### Installer API for Command Line Installations Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/CHANGELOG.txt Refactors the Drupal installer into a programmatic API, enabling command-line installations. This provides greater flexibility for automated deployments and integration with scripting environments. ```APIDOC Installer API: Purpose: Refactored installer into an API. Features: - Allows Drupal to be installed via a command line script. ``` -------------------------------- ### Drupal Multisite Configuration File Search Order Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt This snippet outlines the specific order in which Drupal searches for settings.php files when resolving a site configuration, such as for www.sub.example.com/site3. It shows a hierarchical search from the most specific (full domain and path) to the most general (default), using the first match found. ```Configuration sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php sites/www.sub.example.com/settings.php sites/sub.example.com/settings.php sites/example.com/settings.php sites/default/settings.php ``` -------------------------------- ### Install Composer Dependencies Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/voku/portable-ascii/README.md Installs the necessary project dependencies using Composer, a prerequisite for running the unit tests. ```Bash composer install ``` -------------------------------- ### Install sebastian/version with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/sebastian/version/README.md Instructions for installing the sebastian/version library as a local, per-project dependency or as a development-time dependency using Composer, the PHP package manager. ```bash composer require sebastian/version ``` ```bash composer require --dev sebastian/version ``` -------------------------------- ### Create Mockery object with ordered queries and different parameters Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/getting_started/quick_reference.rst This example shows how to define a specific order for method calls, including calls with different parameters, using named ordered groups. It ensures that 'startup' occurs first, followed by specific 'query' calls in their defined order, and then 'finish'. ```php use \Mockery\Adapter\Phpunit\MockeryTestCase; class DbTest extends MockeryTestCase { public function testOrderedQueries() { $db = \Mockery::mock('db'); $db->shouldReceive('startup')->once()->ordered(); $db->shouldReceive('query')->with('CPWR')->andReturn(12.3)->once()->ordered('queries'); $db->shouldReceive('query')->with('MSFT')->andReturn(10.0)->once()->ordered('queries'); } ``` -------------------------------- ### Install PHP Project Dependencies with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/composer/package-versions-deprecated/CONTRIBUTING.md These commands navigate into the cloned project directory, download the Composer installer, and then use Composer to update and install all necessary project dependencies. ```sh $ cd PackageVersions $ curl -s https://getcomposer.org/installer | php $ php composer.phar update ``` -------------------------------- ### Install Spatie Backtrace via Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/spatie/backtrace/README.md Provides the command to install the `spatie/backtrace` package using Composer, the PHP dependency manager. ```bash composer require spatie/backtrace ``` -------------------------------- ### Install Project Dependencies for Testing Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/react/promise/README.md Run this Composer command from the project root to install all required development dependencies, preparing the environment for running the test suite. ```bash composer install ``` -------------------------------- ### Install sebastian/version with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/sebastian/version/README.md Instructions to add the sebastian/version library as a project dependency using Composer, including development-time installation. ```bash composer require sebastian/version ``` ```bash composer require --dev sebastian/version ``` -------------------------------- ### Generate Psalm Configuration File Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/installation.md Initializes Psalm and generates a configuration file (`psalm.xml`) in your project root. Psalm scans your codebase to determine an appropriate error level based on your existing code. ```bash ./vendor/bin/psalm --init ``` -------------------------------- ### Install HTML5-PHP: Composer JSON Dependency Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/masterminds/html5/README.md To install HTML5-PHP, add the "masterminds/html5" dependency to the "require" section of your "composer.json" file. This ensures Composer manages the library's installation and dependencies. ```JSON { "require" : { "masterminds/html5": "^2.0" } } ``` -------------------------------- ### Install Psalm Phar using Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/installation.md Installs the Psalm Phar (self-contained PHP executable) as a development dependency via Composer. This provides a convenient way to manage the Phar within a Composer-based project. ```bash composer require --dev psalm/phar ``` -------------------------------- ### Install PHPUnit Dependencies Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/codeigniter-4/tests/README.md Installs PHPUnit and other project dependencies using Composer, as defined in the `composer.json` file. ```console composer install ``` -------------------------------- ### Bootstrap New Psalm Plugin Project Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/plugins/authoring_plugins.md Use Composer to quickly set up a new Psalm plugin project from the skeleton repository. After creation, remember to adjust namespaces in `composer.json`, `Plugin.php`, and the `tests` folder to match your project's structure. ```Shell composer create-project weirdan/psalm-plugin-skeleton:dev-master your-plugin-name ``` -------------------------------- ### Install PHP_CodeSniffer with Phive Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/squizlabs/php_codesniffer/README.md Commands to install PHP_CodeSniffer as a project tool using Phive, ensuring the official GPG key is trusted. After installation, the tools can be run directly from the project's `tools` directory. ```Bash phive install --trust-gpg-keys 95DE904AB800754A11D80B605E6DDE998AB73B8E phpcs phive install --trust-gpg-keys 95DE904AB800754A11D80B605E6DDE998AB73B8E phpcbf ``` ```Bash ./tools/phpcs -h ./tools/phpcbf -h ``` -------------------------------- ### Install ReactPHP Promise Library with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/react/promise/README.md Use this Composer command to install the latest supported version of the `react/promise` library, ensuring you get the most recent stable release from the current branch. ```bash composer require react/promise:^3.1 ``` -------------------------------- ### Psalm Command-Line Options Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/command_line_usage.md A reference for key command-line options available in Psalm, including flags for displaying help, integrating with Shepherd, enabling multi-threaded analysis, and utilizing differential analysis for faster builds. ```APIDOC --help: Display all available command-line options. --shepherd: Send build information to https://shepherd.dev. Currently tracks type coverage on 'master' branches. --threads=[n]: Run Psalm's analysis in 'n' number of threads for faster execution. --diff: Only check files updated since the last run (and their dependents). This is turned on by default in Psalm 4. --no-diff: Disable differential analysis (can be used in Psalm 4+ to override the default --diff behavior). ``` -------------------------------- ### Install PHP ArrayToXml package via Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/spatie/array-to-xml/README.md Instructions to install the `spatie/array-to-xml` package using Composer, the PHP dependency manager. ```bash composer require spatie/array-to-xml ``` -------------------------------- ### Install PHP Manifest Library with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/phar-io/manifest/README.md Instructions for adding the `phar-io/manifest` library as a project dependency using Composer. Includes commands for both production and development-only installations. ```shell composer require phar-io/manifest ``` ```shell composer require --dev phar-io/manifest ``` -------------------------------- ### Show All Local Psalm Plugins via CLI Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/plugins/using_plugins.md Run this command to list all Psalm plugins installed locally in your project, including both enabled and disabled ones. ```Bash vendor/bin/psalm-plugin show ``` -------------------------------- ### Install phpunit/php-invoker via Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/phpunit/php-invoker/README.md Instructions for installing the phpunit/php-invoker library using Composer. This includes commands for adding it as a standard project dependency or as a development-only dependency. ```bash composer require phpunit/php-invoker ``` ```bash composer require --dev phpunit/php-invoker ``` -------------------------------- ### Create a Spatie Backtrace Instance Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/spatie/backtrace/README.md Shows the basic way to instantiate the `Spatie\Backtrace\Backtrace` class, which is the entry point for generating backtraces. ```php $backtrace = Spatie\Backtrace\Backtrace::create(); ``` -------------------------------- ### Install sebastian/code-unit-reverse-lookup as a development dependency using Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/sebastian/code-unit-reverse-lookup/README.md This command installs the `sebastian/code-unit-reverse-lookup` library as a development-only dependency for your PHP project. Using the `--dev` flag ensures it's only included during development, for example, when running test suites, and not in production builds. ```bash composer require --dev sebastian/code-unit-reverse-lookup ``` -------------------------------- ### Run Psalm Static Analysis Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/installation.md Executes the Psalm static analysis tool on your project. It will analyze your PHP code and report any identified issues based on your configuration. ```bash ./vendor/bin/psalm ``` -------------------------------- ### Guzzle ClientInterface: Updated get() Method Signature Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/guzzlehttp/guzzle/UPGRADING.md The get() method in Guzzle\Http\ClientInterface has been modified to replace the $body argument with an $options array. You can still pass a resource, string, or EntityBody into the $options parameter to specify the download location of the response. ```APIDOC Guzzle\Http\ClientInterface::get( // Old signature: // $uri = null, $headers = null, $body = null // New signature: $uri = null, $headers = null, $options = array() ) ``` -------------------------------- ### Start CakePHP Built-in Development Server Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/README.md Command to launch the integrated development web server provided by CakePHP. This allows developers to quickly serve their application locally, typically for testing and development purposes. The example starts the server on port 8765. ```bash bin/cake server -p 8765 ``` -------------------------------- ### Install composer/semver library Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/composer/semver/README.md This snippet shows how to install the composer/semver library using Composer, the PHP dependency manager. ```bash composer require composer/semver ``` -------------------------------- ### .env File Assignment Syntax Examples Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/m1/env/README.md Examples demonstrating the flexible assignment syntax for key-value pairs in .env files. It shows various valid formats for assigning values, including optional `export` keyword, and notes that keys cannot start with a number. ```Bash TEST1 = value TEST2= VALUE TEST3 =VALUE TEST4=VALUE TEST5 = VALUE TEST6 = VALUE export TEST1=value ``` -------------------------------- ### Basic Psalm XML Configuration Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/configuration.md A minimal psalm.xml configuration file demonstrating how to specify project files for analysis. This example includes a single directory named 'src'. ```XML ``` -------------------------------- ### Create Mockery object with multiple query and single update calls Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/getting_started/quick_reference.rst This example illustrates setting up a mock object to handle multiple calls to a 'query' method, returning different values, and a single call to an 'update' method. This demonstrates configuring complex interaction patterns for database or service mocks. ```php use \Mockery\Adapter\Phpunit\MockeryTestCase; class DbTest extends MockeryTestCase { public function testDbAdapter() { $mock = \Mockery::mock('db'); $mock->shouldReceive('query')->andReturn(1, 2, 3); $mock->shouldReceive('update')->with(5)->andReturn(NULL)->once(); // ... test code here using the mock } } ``` -------------------------------- ### Create a Mockery spy Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/getting_started/quick_reference.rst This example shows how to create a spy using Mockery. Unlike a mock, a spy does not expect method calls upfront but records them, allowing assertions to be made *after* the code under test has executed, useful for verifying interactions without pre-configuring expectations. ```php $spy = \Mockery::spy('MyClass'); ``` -------------------------------- ### PHP Carbon Usage with Composer Autoload Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/nesbot/carbon/readme.md Example PHP code demonstrating how to include Carbon in a project after installing it via Composer, using Composer's autoloader. ```php pushHandler(new StreamHandler('path/to/your.log', Level::Warning)); // add records to the log $log->warning('Foo'); $log->error('Bar'); ``` -------------------------------- ### Install sebastian/comparator with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/sebastian/comparator/README.md Installs the sebastian/comparator library as a stable, production dependency using Composer. This command adds the package to your project's composer.json and downloads it. ```Shell composer require sebastian/comparator ``` -------------------------------- ### Initialize Phinx Configuration Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/robmorgan/phinx/docs/en/install.rst This command initializes the Phinx configuration file within your project, setting up the necessary structure for database migrations. Before running, ensure the 'db/migrations' folder exists in your project and has adequate write permissions. ```bash vendor/bin/phinx init ``` -------------------------------- ### Generate PHP Code Coverage Report Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/phpunit/php-code-coverage/README.md This PHP example demonstrates how to initialize `php-code-coverage`, include specific files for analysis, start and stop coverage collection for a test, and generate an HTML report. ```php includeFiles( [ '/path/to/file.php', '/path/to/another_file.php', ] ); $coverage = new CodeCoverage( (new Selector)->forLineCoverage($filter), $filter ); $coverage->start(''); // ... $coverage->stop(); (new HtmlReport)->process($coverage, '/tmp/code-coverage-report'); ``` -------------------------------- ### Enable a Psalm Plugin via CLI Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/plugins/using_plugins.md After installation, use the psalm-plugin tool to enable a specific plugin. This makes the plugin active for Psalm analysis. Replace plugin-vendor/plugin-package with the installed plugin's name. ```Bash vendor/bin/psalm-plugin enable plugin-vendor/plugin-package ``` -------------------------------- ### PHPUnit Test Method Naming Convention Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/codeigniter-4/tests/README.md Examples of method names for individual tests within a test class. Method names must start with 'test' and should be descriptive of the functionality being tested. ```PHP testUserCanModifyFile() testOutputColorMatchesInput() testIsLoggedInFailsWithInvalidUser() ``` -------------------------------- ### Basic Usage of CakePHP Chronos Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/cakephp/chronos/README.md This example shows how to include the Chronos library and get the current date and time using Chronos::now(). It demonstrates a fundamental use case for creating a Chronos object. ```php with the actual plugin name. ```Bash composer require --dev ``` -------------------------------- ### PHP: Example of PropertyNotSetInConstructor Issue Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/issues/PropertyNotSetInConstructor.md This PHP code demonstrates a class 'A' with a public property '$foo' declared as a string but not initialized in the constructor. This setup would trigger Psalm's PropertyNotSetInConstructor issue, as the property is non-nullable and lacks a default value. ```php get('Articles'); ``` -------------------------------- ### Psalm Configuration with XInclude - Main File (psalm.xml) Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/configuration.md An example of psalm.xml utilizing XInclude to split configuration into multiple files. This main file includes files.xml for project file definitions, demonstrating how to modularize Psalm's configuration. ```XML ``` -------------------------------- ### Install PHP_CodeSniffer Composer Installer Plugin Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md Installs the PHP_CodeSniffer Composer Installer plugin as a development dependency using Composer. The --dev flag ensures it's only installed for development environments. ```bash composer require --dev dealerdirect/phpcodesniffer-composer-installer ``` -------------------------------- ### Install CakePHP Plugin Installer with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/cakephp/plugin-installer/README.md Installs the `cakephp/plugin-installer` package into your CakePHP application using Composer, making your application aware of installed plugins. ```bash composer require cakephp/plugin-installer:* ``` -------------------------------- ### Create CakePHP 5.x Application with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/README.md Demonstrates various methods to initialize a new CakePHP 5.x project using Composer. Examples include using the composer.phar executable, a globally installed Composer, and specifying a custom application directory name during creation. ```bash php composer.phar create-project --prefer-dist cakephp/app [app_name] ``` ```bash composer create-project --prefer-dist cakephp/app ``` ```bash composer create-project --prefer-dist cakephp/app myapp ``` -------------------------------- ### Initialize and Use Symfony Translator for String Translation Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/symfony/translation/README.md This PHP code initializes the Symfony Translator for French (fr_FR). It demonstrates adding translation resources via ArrayLoader and translating a string using the trans method. The example shows basic setup for internationalizing text. ```php use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\Loader\ArrayLoader; $translator = new Translator('fr_FR'); $translator->addLoader('array', new ArrayLoader()); $translator->addResource('array', [ 'Hello World!' => 'Bonjour !', ], 'fr_FR'); echo $translator->trans('Hello World!'); // outputs « Bonjour ! » ``` -------------------------------- ### Clone PHP Project Repository Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/composer/package-versions-deprecated/CONTRIBUTING.md This command clones the project repository from GitHub to your local machine, initiating the setup process for development. ```sh $ git clone git://github.com/Ocramius/PackageVersions.git ``` -------------------------------- ### Run Psalm from Project Root Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/command_line_usage.md Execute Psalm from your project's root directory. This command will initiate a scan of all files specified within the `` section of your Psalm configuration. ```bash ./vendor/bin/psalm ``` -------------------------------- ### Initialize PHP PharStreamWrapper with Single PharExtensionInterceptor Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/misc/typo3/phar-stream-wrapper/README.md This example shows how to configure the PharStreamWrapper\Manager to use only the PharExtensionInterceptor. This setup ensures that only Phar archives with a .phar file extension are processed, taking into account symbolic links and internal Phar aliases for robust validation. ```PHP $behavior = new \TYPO3\PharStreamWrapper\Behavior(); \TYPO3\PharStreamWrapper\Manager::initialize( $behavior->withAssertion(new PharExtensionInterceptor()) ); ``` -------------------------------- ### PHP Example: Accessing Static Property in Pure Function Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/issues/ImpureStaticProperty.md Illustrates the PHP code that triggers the `ImpureStaticProperty` error in Psalm, showing a pure function attempting to access a static property. The `get` method is marked as pure but accesses the static property `$value`, which is considered impure. ```php 3.1416, 'e' => 2.71)); $this->assertEquals(3.1416, $mock->pi()); $this->assertEquals(2.71, $mock->e()); } } ``` -------------------------------- ### Define Composer Package for PHP_CodeSniffer Standard Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md This composer.json example defines a Composer package for a custom PHP_CodeSniffer standard. It specifies the package name, description, required PHP and PHP_CodeSniffer versions, and crucially, sets the package type to 'phpcodesniffer-standard' for proper recognition by the plugin. ```JSON { "name" : "acme/phpcodesniffer-our-standards", "description" : "Package contains all coding standards of the Acme company", "require" : { "php" : ">=5.4.0", "squizlabs/php_codesniffer" : "^3.6" }, "type" : "phpcodesniffer-standard" } ``` -------------------------------- ### Allow Mockery to Mock Protected Methods in PHP Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/reference/protected_methods.rst This example demonstrates how to configure Mockery to allow mocking of protected methods for a specific class. It shows a class definition with a protected method and the Mockery setup using `shouldAllowMockingProtectedMethods()` to enable mocking of that method, followed by a call to `shouldReceive()`. ```php class MyClass { protected function foo() { } } $mock = \Mockery::mock('MyClass') ->shouldAllowMockingProtectedMethods(); $mock->shouldReceive('foo'); ``` -------------------------------- ### Measure resource usage since PHP startup Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/phpunit/php-timer/README.md This PHP snippet demonstrates how to measure resource usage (time and memory) from the start of the PHP request using `SebastianBergmann\Timer\ResourceUsageFormatter::resourceUsageSinceStartOfRequest()`. It's useful for getting an overall picture of script consumption, though it notes the reliance on `$_SERVER['REQUEST_TIME_FLOAT']` which can be unreliable. ```php require __DIR__ . '/vendor/autoload.php'; use SebastianBergmann\Timer\ResourceUsageFormatter; foreach (\range(0, 100000) as $i) { // ... } print (new ResourceUsageFormatter)->resourceUsageSinceStartOfRequest(); ``` -------------------------------- ### Define PHP Temperature Class Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/getting_started/simple_example.rst This PHP code defines a `Temperature` class. It takes a service object in its constructor and calculates an average temperature by calling the `readTemp` method on the service three times. This class is designed to interact with an external data source, which is abstracted by the `$service` dependency. ```php class Temperature { private $service; public function __construct($service) { $this->service = $service; } public function average() { $total = 0; for ($i=0; $i<3; $i++) { $total += $this->service->readTemp(); } return $total/3; } } ``` -------------------------------- ### Verify Installed PHP_CodeSniffer Standards Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md Command to list all currently installed PHP_CodeSniffer coding standards after running composer install in a project configured with the installer plugin. This confirms successful integration. ```bash ./vendor/bin/phpcs -i ``` -------------------------------- ### Install PHP_CodeSniffer Composer Installer Plugin Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md Use Composer to install the PHP_CodeSniffer Composer Installer Plugin as a development dependency. This command adds the plugin to your project's `composer.json` and downloads its dependencies. ```bash composer require --dev dealerdirect/phpcodesniffer-composer-installer ``` -------------------------------- ### Initialize Phinx Project Configuration Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/robmorgan/phinx/docs/en/commands.rst The Init command prepares a project for Phinx by generating the configuration file, typically `phinx.php`, in the project root. Users can specify a custom location, filename, or format (php, yml, json) for the configuration file. This command is essential for setting up Phinx. ```bash $ phinx init ``` ```bash $ phinx init ./custom/location/ ``` ```bash $ phinx init custom-config.yml ``` ```bash $ phinx init --format yml ``` -------------------------------- ### PHP: Mockery Mock Arrange-Expect-Act-Assert Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/reference/spies.rst This example demonstrates the traditional Mockery mock approach. It involves arranging the test setup, explicitly setting expectations on the mock before the action, performing the action on the System Under Test (SUT), and finally asserting that the expectations were met. This style ensures strict adherence to defined interactions. ```php // arrange $mock = \Mockery::mock('MyDependency'); $sut = new MyClass($mock); // expect $mock->shouldReceive('foo') ->once() ->with('bar'); // act $sut->callFoo(); // assert \Mockery::close(); ``` -------------------------------- ### Revoke Drupal Documentation File Permissions on Unix/Linux Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt This command demonstrates how to remove read permissions for a specific file (CHANGELOG.txt) on Unix/Linux systems using the `chmod` utility. This is an optional security measure to make it slightly more difficult to determine the exact Drupal version running on the server. ```Shell chmod a-r CHANGELOG.txt ``` -------------------------------- ### Integrate Mockery with PHPUnit by extending MockeryTestCase Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/mockery/mockery/docs/getting_started/quick_reference.rst This snippet demonstrates how to integrate Mockery with PHPUnit by extending the `MockeryTestCase` class. This approach provides a convenient way to use Mockery's features within PHPUnit tests, handling setup and teardown automatically. ```php use \Mockery\Adapter\Phpunit\MockeryTestCase; class MyTest extends MockeryTestCase { } ``` -------------------------------- ### Guzzle Client Request Handling: 3.x vs 4.x Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laravel-11/vendor/guzzlehttp/guzzle/UPGRADING.md Compares request creation and sending in Guzzle 3.x and 4.x. In 4.x, methods like `get()` directly return a response. The snippet also shows how to replicate the Guzzle 3.x behavior of creating a request object first. ```PHP // 3.0 $request = $client->get('/'); $response = $request->send(); // 4.0 $response = $client->get('/'); // or, to mirror the previous behavior $request = $client->createRequest('GET', '/'); $response = $client->send($request); ``` -------------------------------- ### Install PHP Version Library with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/phar-io/version/README.md Instructions for adding the `phar-io/version` library as a project dependency using Composer. It covers both standard production dependencies and development-only dependencies. ```shell composer require phar-io/version ``` ```shell composer require --dev phar-io/version ``` -------------------------------- ### PHP Example: Reading User-Controlled File Content Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/vimeo/psalm/docs/running_psalm/issues/TaintedFile.md This PHP code snippet demonstrates a 'TaintedFile' vulnerability where user-controlled input from the GET superglobal directly specifies the file to be read using 'file_get_contents'. This can lead to sensitive data exposure if an attacker manipulates the 'header' parameter to access arbitrary files on the server. ```php getHomeDir(); echo $xdg->getHomeConfigDir(); echo $xdg->getHomeDataDir(); echo $xdg->getHomeCacheDir(); echo $xdg->getRuntimeDir(); print_r($xdg->getDataDirs()); // returns array print_r($xdg->getConfigDirs()); // returns array ``` -------------------------------- ### Example XML Output of a Phar.io Manifest Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/phar-io/manifest/README.md This XML snippet represents the serialized output of a `PharIo\Manifest\Manifest` object. It shows the structure of a Phar.io manifest, including the main application details, copyright information with license, and a `bundles` section listing included components like 'vendor/packageA'. ```xml ``` -------------------------------- ### Define Custom PHP_CodeSniffer Standard Composer Package Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/cakephp-5/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md This `composer.json` example shows how to create a Composer package for a custom PHP_CodeSniffer coding standard. It defines the package name, description, required PHP and PHP_CodeSniffer versions, and crucially, sets the package `type` to `phpcodesniffer-standard` for proper plugin integration. ```json { "name" : "acme/phpcodesniffer-our-standards", "description" : "Package contains all coding standards of the Acme company", "require" : { "php" : ">=5.4.0", "squizlabs/php_codesniffer" : "^3.6" }, "type" : "phpcodesniffer-standard" } ``` -------------------------------- ### Install HTML5-PHP: Composer Command Line Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/vendor/masterminds/html5/README.md Alternatively, use the Composer "require" command directly from your terminal. This command automatically adds the dependency to your "composer.json" and installs the package. ```bash composer require masterminds/html5 ``` -------------------------------- ### Configure Drupal Cron Job with Wget in Crontab Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/drupal-7.95/INSTALL.txt This crontab entry sets up an automated process to trigger Drupal's cron tasks hourly using the `wget` command. It visits the `cron.php` page with a site-specific cron key, ensuring authorized access and independent execution of maintenance tasks. ```Shell 0 * * * * wget -O - -q -t 1 http://example.com/cron.php?cron_key=YOURKEY ``` -------------------------------- ### Create new Laminas MVC project with Composer Source: https://github.com/seanmorris/php-wasm/blob/master/demo-node/persist/laminas-3/README.md Use Composer to create a new Laminas MVC project. This command initializes the project structure in the specified path. ```bash composer create-project -sdev laminas/laminas-mvc-skeleton path/to/install ```