strangebuzz / microsymfony
A template to initialize an application to use Symfony as a micro-framework
Installs: 70
Dependents: 0
Suggesters: 0
Security: 0
Stars: 95
Watchers: 2
Forks: 8
Open Issues: 7
Type:symfony-application-template
Requires
- php: >=8.2
- ext-ctype: *
- ext-dom: *
- ext-iconv: *
- ext-libxml: *
- ext-mbstring: *
- ext-simplexml: *
- ext-xml: *
- league/commonmark: ^2.4
- symfony/asset: ~7.2.0
- symfony/asset-mapper: ~7.2.0
- symfony/console: ~7.2.0
- symfony/dotenv: ~7.2.0
- symfony/flex: ^2
- symfony/form: ~7.2.0
- symfony/framework-bundle: ~7.2.0
- symfony/http-foundation: ~7.2.0
- symfony/http-kernel: ~7.2.0
- symfony/intl: ~7.2.0
- symfony/monolog-bundle: ^3.8
- symfony/routing: ~7.2.0
- symfony/runtime: ~7.2.0
- symfony/security-csrf: ~7.2.0
- symfony/stimulus-bundle: ^2.0
- symfony/string: ~7.2.0
- symfony/twig-bundle: ~7.2.0
- symfony/ux-turbo: ^2.16
- symfony/validator: ~7.2.0
- symfony/web-link: ~7.2.0
- symfony/yaml: ~7.2.0
- twig/extra-bundle: ^3.0
- twig/markdown-extra: ^3.7
- twig/twig: ^3.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.0
- roave/security-advisories: dev-latest
- symfony/browser-kit: ~7.2.0
- symfony/css-selector: ~7.2.0
- symfony/maker-bundle: ^1.61
- symfony/requirements-checker: ^2.0
- symfony/stopwatch: ~7.2.0
- symfony/web-profiler-bundle: ~7.2.0
- symplify/config-transformer: ^12.3
Conflicts
- dev-main
- 7.2.1
- 7.2.0
- 7.1.9
- 7.1.8
- 7.1.7
- 7.1.6
- 7.1.5
- 7.1.4
- 7.1.2
- 7.1.1
- 7.1.0
- 7.0.6
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 6.3.8
- 6.3.7
- 6.3.6
- 6.3.5
- 6.3.4
- 6.3.3
- 6.3.1
- 6.2.0
- dev-chore/cleanup
- dev-chore/better-php-config
- dev-frankenphp
- dev-doctrine-dbal
- dev-feat/use-twig-cs-fixer
- dev-twigstan
- dev-symfony-docker
- dev-eloquent
This package is auto-updated.
Last update: 2024-12-29 20:43:50 UTC
README
About ๐
MicroSymfony is a Symfony 7.2 application skeleton on steroids, ready to use.
I have made a long blog post explaining the philosophy behind and how to use it:
One rule: the only mandatory dependency is PHP!
PS: If you want to use the last Symfony 6.4 LTS version in your
composer.json
file, replace all occurrences of7.2
with6.4
and runcomposer up
.
Table of Contents ๐
- Demos
- Quick-start
- Requirements
- Stack
- Features
- Feature branches
- Notes
- Other good practices
- References
- Contributing
- Security
- Credits
- License
- Built with MicroSymfony
Demos ๐
Because a live demo is always better than all explanations:
- Live demo at https://microsymfony.ovh
- Live demo powered by FrankenPHP at https://frankenphp.microsymfony.ovh
Quick-start โก
With the Symfony binary ๐ถ
You must have the Symfony binary and composer installed locally.
To create a new project, from the last tag, run:
composer create-project strangebuzz/microsymfony && cd microsymfony
Then start the PHP server with make:
make start
Or with Castor:
castor start
Open https://127.0.0.1:8000 (considering your 8000 port is free) and enjoy! ๐
PS: You can also use the green button "Use this template โฉ" at the top right of the GitHub project homepage. This creates a new repository from the main branch instead of the last release. I guarantee that all commits on the main are stable; you can verify that the associated CI jobs are โ .
With FrankenPHP ๐งโ
We can also use FrankenPHP to run MicroSymfony. You must have Docker installed locally.
Create a new project from the GitHub template, run:
docker run --rm -it -v $PWD:/app composer:latest create-project strangebuzz/microsymfony && cd microsymfony
Install the FrankenPHP Symfony runtime:
docker run --rm -it -v $PWD:/app composer:latest require runtime/frankenphp-symfony
Then run:
docker run \
-e FRANKENPHP_CONFIG="worker ./public/index.php" \
-e APP_RUNTIME=Runtime\\FrankenPhpSymfony\\Runtime \
-v $PWD:/app \
-p 80:80 -p 443:443 \
-d \
dunglas/frankenphp
Open https://localhost and enjoy! ๐
PS: On Windows, replace $PWD
with "%cd%"
.
You can also directly use the FrankenPHP branch.
Requirements โ
- PHP 8.2 (also works with PHP 8.3 and PHP 8.4)
- The Symfony CLI
Optional requirements ๐ฆ
- The Xdebug PHP extension if you want to run the code coverage report
- Castor task runner if you don't want to use Make and its Makefile
Stack ๐
Features ๐
MicroSymfony ships these features, ready to use:
- Two task runners
- Static analysis with PHPStan 2
- Coding standards with php-cs-fixer
- Tests (demo)
- Code coverage at 100% (configurable threshold)
- GitHub CI (actions)
- Asset mapper+Stimulus (documentation)
- A custom error template
Feature branches ๐
Feature branches
are not merged in the main branch but are used to test the integration of a new
vendor library or make a POC.
For example, have you ever dreamed of testing Eloquent,
the Laravel ORM, on a Symfony project?
Then clone the eloquent
branch, and run composer install && make load-fixtures
.
Infrastructure
Database ๐ฝ
These ยซ database ยป branches aim to display a list of records from a SQLite database.
Tooling ๐จ
- Taskfile (PR, branch, rebased on 2024-11-17)
- TwigStan (PR, branch, rebased on 2024-11-17)
- Twig-CS-Fixer (PR, branch, rebased on 2024-11-21)
One will rebase those branches regularly so they are always up to date.
Notes ๐
Symfony-UX
Turbo forms are disabled in assets/app.js.
To enable the feature for a given form, add the data-turbo="true"
attribute to it.
Or change the parameter Turbo.setFormMode
to on
to activate the feature globally.
In both cases, your controller code has to be modified accordingly.
PHP configuration files
If you install a new Symfony library, the flex recipes can add YAML files to your
project.
These YAML files are loaded, but you can convert them to PHP like the other configuration
files.
For example, to convert the messenger
YAML configuration to PHP with Simplify,
run:
vendor/bin/config-transformer convert config/packages/messenger.yaml
Other good practices ๐
- Using PHP configuration files instead of YAML (source)
- Using strict types in all PHP files (source)
- Using the ADR pattern in an action controller (source) (doc)
- The composer.json file is normalized with ergebnis/composer-normalize
- Use of the composer bin plugin to install and run php-cs-fixer
References ๐
- How to Switch from YAML Configs to PHP Today with Symplify (tomasvotruba.com)
- PHPStan 2.0 Released With Level 10 and Elephpants! (phpstan.org)
- A better ADR pattern for your Symfony controllers (strangebuzz.com)
- My Taskfile configuration for Symfony (jmsche.fr)
- You should be using PHPStans bleeding edge (backendtea.com)
- A Good Naming Convention for Routes, Controllers and Templates? (jolicode.com)
- Front-end application development, Symfony-style(s) (dunglas.dev)
- Automated Test Coverage Checks with Travis, PHPUnit for Github Pull Requests (ocramius.github.io)
- Installing and using php-cs-fixer (strangebuzz.com)
- Castor, a journey across the sea of task runners (jolicode.com)
- Initializing your Symfony project with solid foundations (strangebuzz.com)
- Organizing your Symfony project tests (strangebuzz.com)
- What are your Symfony best practices? (strangebuzz.com)
- Setting a CI/CD workflow for a Symfony project thanks to the GitHub actions (strangebuzz.com)
- The Symfony Framework Best Practices (symfony.com)
Contributing ๐ค
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security ๐งฏ
Please see SECURITY for details.
Credits ๐
- COil (primary maintainer)
- All Contributors
License โ๏ธ
The MIT License (MIT). Please see License File for more information.
Built with MicroSymfony ๐ ๏ธ
- Placehold.ovh (2024-12-01)
- Appartement-tourcoing.com (2024-11-30)
- Easyadmin Mercure Demo (2023-05-24)