Updated: 25 January 2025
Symfony releases, notifications and release checker
Add a pack for Apache support in Symfony
composer require symfony/apache-pack
Freelance software engineer United Kingdom
Updated: 25 January 2025
Symfony releases, notifications and release checker
Add a pack for Apache support in Symfony
composer require symfony/apache-pack
Updated: 10 December 2024
See https://symfony.com/doc/current/testing.html
KernelTestCase.WebTestCase.The output of make:test supplies a useful summary
root@5b8333e33939:/var/www/html# bin/console make:test
Which test type would you like?:
[TestCase ] basic PHPUnit tests
[KernelTestCase ] basic tests that have access to Symfony services
[WebTestCase ] to run browser-like scenarios, but that do not execute JavaScript code
[ApiTestCase ] to run API-oriented scenarios
[PantherTestCase] to run e2e scenarios, using a real-browser or HTTP client and a real web server
Updated: 09 May 2023
echo '<pre>';
$e = new \Exception;
var_dump($e->getTraceAsString());
echo '</pre>';
die;
https://stackoverflow.com/questions/1423157/print-php-call-stack
Updated: 27 July 2024
Install Composer phar
curl -sS https://getcomposer.org/installer | php
Circumvent php memory limit
php -d memory_limit=-1 composer.phar install
Up / downgrade Composer itself
composer self-update --help
composer self-update --1
composer self-update --2
Updated: 17 January 2023
Require a new project as a dependency
docker run --rm \
-v $(pwd):/app \
composer/composer:latest \
require slim/slim "^3.0"
Install all dependencies in a project
docker run --rm --interactive --tty --volume $PWD:/app composer install
Updated: 22 December 2022
Updated: 17 May 2024
Pre-configured Docker images (including Xdebug) from Jetbrains https://github.com/JetBrains/phpstorm-docker-images
Run a php script
docker run -it --rm --name my-running-script \
-v "$PWD":/usr/src/myapp \
-w /usr/src/myapp \
php:7.4-cli php script.php
Run the php development server
docker run -it --rm --name php-server \
-v "$PWD":/usr/src/myapp \
-w /usr/src/myapp \
-p 8000:8000 \
php:8.2-cli php -S 0.0.0.0:8000
Updated: 06 May 2024
Set folder and file permissions for a php project
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
Updated: 26 November 2024
Two scripts: phpcs and phpcbf
https://github.com/squizlabs/PHP_CodeSniffer
A set of rules for Squizlabs PHP_CodeSniffer
https://github.com/WordPress/WordPress-Coding-Standards
https://cs.symfony.com/
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer
Updated: 26 November 2024
Attempt to activate and display all errors, warnings, deprecations and notices
error_reporting(E_ALL);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', 'php-error.log')
// check the settings above
trigger_error('This is E_USER_DEPRECATED', E_USER_DEPRECATED);
trigger_error('This is E_USER_NOTICE', E_USER_NOTICE);
trigger_error('This is E_USER_WARNING', E_USER_WARNING);
trigger_error('This is E_USER_ERROR', E_USER_ERROR);
This script demonstrates how to temporarily adjust which PHP errors are reported, to avoid displaying a deprecation notice to users
// Activate every error, warning, deprecation & notice.
error_reporting(E_ALL);
// Get the current error reporting value.
$error_reporting = error_reporting();
// Reset the error reporting value but now excluding E_DEPRECATED.
error_reporting($error_reporting & ~E_DEPRECATED);
// With PHP 7.4, trigger an E_DEPRECATED.
get_magic_quotes_gpc();
// No deprecation message.
// Reset error reporting to original value.
error_reporting($error_reporting);
// Attempt to trigger an E_DEPRECATED.
get_magic_quotes_gpc();
// Deprecation message here.