November 30, 2017 release of symfony 4.0 will take place
The fourth version has a number of global changes, the main of which can be called the transition to symfony Flex.')
What is symfony flex?
This is a new approach to organizing applications on a symphony, based on
"recipes" .
According to the developers, this should make it easier to work with dependencies \ bundles \ packages and introduce more automation.
There are 2 repositories with recipes:
The recipe is configured via
manifest.json which contains a set of configurators and options.
Options
aliasesUsed to specify an alternative recipe name. For example, without using this option, the recipe is set as follows:
composer req acme-inc/acme-log-monolog-handler
Adding to
manifest.json { "aliases": ["acme-log", "acmelog"] }
can be used
composer req acme-log
Configurators
A set of tasks to be performed when installing a recipe.bundlesConnecting one or more bundles with the ability to specify the environment.
{ "bundles": { "Symfony\\Bundle\\DebugBundle\\DebugBundle": ["dev", "test"], "Symfony\\Bundle\\MonologBundle\\MonologBundle": ["all"] } }
containerAdding container parameters to services.yaml, for example, locale:
{ "container": { "locale": "en" } }
copy-from-packageCopies folders or files from the package to the project:
{ "copy-from-package": { "bin/check.php": "%BIN_DIR%/check.php" } }
Available constants:
% BIN_DIR%,% CONF_DIR%,% CONFIG_DIR%,% SRC_DIR%% VAR_DIR%,% PUBLIC_DIR%
copy-from-recipeCopying files and directories from the recipe itself:
"copy-from-recipe": { "config/": "%CONFIG_DIR%/", "src/": "%SRC_DIR%/" }
envAdding parameters to .env and .env.dist:
{ "env": { "APP_ENV": "dev", "APP_DEBUG": "1" } }
You can generate a random 16-bit string using
% generate (secret)%gitignoreAdds patterns to .gitignore:
{ "gitignore": [ ".env", "/public/bundles/", "/var/", "/vendor/" ] }
post-install-outputDefines the content that will be shown after the installation of the recipe, must be defined in the
post-install.txt file , each line is closed by PHP_EOL.
Console colors / styles are supported.
A complete example of manifest.json for
symfony / framework-bundle :
{ "bundles": { "Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle": ["all"] }, "copy-from-recipe": { "config/": "%CONFIG_DIR%/", "public/": "%PUBLIC_DIR%/", "src/": "%SRC_DIR%/" }, "composer-scripts": { "make cache-warmup": "script", "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd" }, "env": { "APP_ENV": "dev", "APP_DEBUG": "1", "APP_SECRET": "%generate(secret)%" }, "gitignore": [ ".env", "/public/bundles/" "/var/", "/vendor/" ] }
We collect the first project on symfony Flex
We will use the latest version available at the time of this writing -
"v4.0.0-RC1"First we need
composer .
Let's create a project:
composer create-project symfony/skeleton flex-test-project "v4.0.0-RC1"
Initially, only official recipes are available to us. To use third-party recipes, you must do the following:
composer config extra.symfony.allow-contrib true
or add yourself
"extra": { "symfony": { "allow-contrib": "true" }
in
composer.jsonTo start, you can use the PHP-integrated web server or install the web-server-bundle through its recipe:
composer req web-server bin/console server:start
Also, we need a profiler and a generator, which is now called
maker-bundle .
Profiler requires twig.
composer req twig composer req web-profiler-bundle
And for the annotation generator it may also be necessary to lower the minimum-stability requirements in * composer.json *.
"minimum-stability": "dev"
composer req maker composer req annotations bin/console make:controller
Is done.
You can use https://symfony.sh/ to search for recipes.Major changes in the upcoming version .Github repositoryUpgrade from 3. * to 4. *