Search by

elkuku / symfony-utils

elkuku

Various Symfony Utilities

Package info

github.com/elkuku/symfony-utils

pkg:composer/elkuku/symfony-utils

Statistics

Installs: 2 107

Dependents: 2

Suggesters: 0

Stars: 1

Open Issues: 0

0.6.1 2026-11-18 16:14 UTC

This package is auto-updated.

Last update: 2026-11-29 20:12:38 UTC


README

  • Dev environment scripts for bin/, installed by a Flex recipe (see below).
  • UserAdminBaseCommand: an interactive user-admin console command. Extend it and implement getRoles() and setRole(). If your user entity has more required fields, override fillNewUser() to ask for them when a user is created. Needs symfony/console, symfony/security-core, doctrine/orm and doctrine/doctrine-bundle.
  • ControllerBaseTest: a smoke test that requests every route of your controllers and checks the status codes. Needs symfony/framework-bundle and symfony/browser-kit.

The package itself only requires PHP. The packages the two classes need are suggested, not required, so a project that only wants the scripts doesn't get Doctrine installed.

Dev environment scripts

The package ships shell scripts for setting up and running a Symfony project locally. A Symfony Flex recipe copies them into the project's bin/ folder:

Script What it does
bin/install composer install, starts the Docker Compose services, runs the Doctrine migrations, loads the fixtures on a fresh database, starts the Symfony server
bin/start Starts the Docker Compose services and the Symfony server
bin/stop Stops the Symfony server and the Docker Compose services
bin/deploy Runs on the server: composer install --no-dev, dump-env prod, compiles the assets, runs the Doctrine migrations. Set PHP_BIN/COMPOSER_BIN to use other binaries, DEPLOY_GIT_DIR to write sha.txt
bin/functions.sh Helpers used by the scripts above

Each step is skipped when the project doesn't use it (no compose.yaml, no Doctrine migrations, no fixtures). Before migrating, bin/install waits up to 30 seconds for the database, so the Docker database service doesn't need a healthcheck. Fixtures are only loaded when no migration had been run before, because loading them purges the database.

Server-specific deploy settings

bin/deploy uses php and composer from the PATH. If the server needs other binaries (e.g. Plesk with several PHP versions), put them into bin/deploy.env in your project. The recipe never touches that file:

PHP_BIN=/opt/plesk/php/8.5/bin/php
COMPOSER_BIN=/usr/lib/plesk-9.0/composer.phar

A deploy without a .git folder, e.g. by the Plesk Git extension, can't tell which commit it runs. Set DEPLOY_GIT_DIR to the Git repository the code comes from, and bin/deploy writes the commit of its HEAD to sha.txt in the project folder. For the Plesk Git extension, this is the bare repository of the site:

DEPLOY_GIT_DIR="$HOME/git/<project>.git"

If the repository can't be read, the deploy shows a warning and goes on. Add sha.txt to the project's .gitignore.

Requirements

The local scripts need the Symfony CLI, and Docker with Compose v2 (docker compose) if the project has a Compose file. bin/deploy only needs PHP and Composer, and Git for DEPLOY_GIT_DIR.

Installing the scripts

The recipe lives in a custom Flex endpoint, elkuku/recipes. Add it to your project's composer.json:

"extra": {
    "symfony": {
        "endpoint": [
            "https://api.github.com/repos/elkuku/recipes/contents/index.json?ref=flex/main",
            "flex://defaults"
        ]
    }
}

Then install the package, or, if it is already installed, install its recipe:

composer require elkuku/symfony-utils
# or
composer recipes:install elkuku/symfony-utils

Flex asks before overwriting scripts that already exist in bin/; add --force to replace them.

Development

composer install
composer check   # PHPStan, PHP CS Fixer, PHPUnit
shellcheck -x -P SCRIPTDIR resources/bin/*

CI runs these on every push and pull request, and lints src/ with PHP 8.1, the lowest supported version.