Flex: Recipes not applied

Created on 18 May 2017  ยท  9Comments  ยท  Source: symfony/flex

When I clone symfony/skeleton and run composer install myself, it doesn't seem to produce the same result as if I'd run composer create-project symfony/skeleton:3.3.x-dev demo. Indeed, symfony/flex doesn't seem to work if you don't run create-project.

When I create my own skeleton and run composer install

> composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 22 installs, 0 updates, 0 removals
  - Installing symfony/flex (dev-master 40c8b45): Loading from cache
  - Installing symfony/stopwatch (3.4.x-dev 162ab93): Loading from cache
  - Installing symfony/routing (3.4.x-dev 6dbb39f): Loading from cache
  - Installing symfony/polyfill-mbstring (dev-master e79d363): Loading from cache
  - Installing psr/log (dev-master 4ebe3a8): Loading from cache
  - Installing symfony/debug (3.4.x-dev 627c397): Loading from cache
  - Installing symfony/http-foundation (3.4.x-dev 3e35088): Loading from cache
  - Installing symfony/event-dispatcher (3.4.x-dev dc71961): Loading from cache
  - Installing symfony/http-kernel (3.4.x-dev 755a852): Loading from cache
  - Installing symfony/finder (3.4.x-dev a90f2ad): Loading from cache
  - Installing symfony/filesystem (3.4.x-dev 45e8dd4): Loading from cache
  - Installing psr/container (dev-master b7ce3b1): Loading from cache
  - Installing symfony/dependency-injection (3.4.x-dev fee0f72): Loading from cache
  - Installing symfony/config (3.4.x-dev de6faa2): Loading from cache
  - Installing symfony/class-loader (3.4.x-dev 8c7ae3c): Loading from cache
  - Installing psr/simple-cache (dev-master 753fa59): Loading from cache
  - Installing psr/cache (dev-master 78c5a01): Loading from cache
  - Installing symfony/cache (3.4.x-dev a56a943): Loading from cache
  - Installing doctrine/cache (dev-master 0da649f): Loading from cache
  - Installing symfony/framework-bundle (3.4.x-dev d3053f4): Loading from cache
  - Installing symfony/yaml (3.4.x-dev 19248c8): Loading from cache
  - Installing symfony/dotenv (3.4.x-dev c6eb017): Loading from cache
Writing lock file
Generating autoload files

> tree -La 2
.
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ composer.lock
โ””โ”€โ”€ vendor
    โ”œโ”€โ”€ autoload.php
    โ”œโ”€โ”€ composer
    โ”œโ”€โ”€ doctrine
    โ”œโ”€โ”€ psr
    โ””โ”€โ”€ symfony

As you can see, no recipe has been applied.

When I run composer create-project symfony/skeleton:3.3.x-dev demo

> composer create-project symfony/skeleton:3.3.x-dev flex-demo
Installing symfony/skeleton (3.3.x-dev 19daacfd7ca93335963b7dd0e5ea4e18c228135c)
  - Installing symfony/skeleton (3.3.x-dev 19daacf): Cloning 19daacfd7c
Created project in flex-demo
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 22 installs, 0 updates, 0 removals
  - Installing symfony/flex (dev-master 40c8b45): Downloading (100%)
    Detected auto-configuration settings for "symfony/flex"
    Setting configuration and copying files
  - Installing symfony/stopwatch (3.4.x-dev 162ab93): Downloading (100%)
  - Installing symfony/routing (3.4.x-dev 6dbb39f): Downloading (100%)
  - Installing symfony/polyfill-mbstring (dev-master e79d363): Loading from cache
  - Installing psr/log (dev-master 4ebe3a8): Downloading (100%)
  - Installing symfony/debug (3.4.x-dev 627c397): Downloading (100%)
  - Installing symfony/http-foundation (3.4.x-dev 3e35088): Downloading (100%)
  - Installing symfony/event-dispatcher (3.4.x-dev dc71961): Downloading (100%)
  - Installing symfony/http-kernel (3.4.x-dev 755a852): Downloading (100%)
  - Installing symfony/finder (3.4.x-dev a90f2ad): Downloading (100%)
  - Installing symfony/filesystem (3.4.x-dev 45e8dd4): Downloading (100%)
  - Installing psr/container (dev-master b7ce3b1): Downloading (100%)
  - Installing symfony/dependency-injection (3.4.x-dev fee0f72): Downloading (100%)
  - Installing symfony/config (3.4.x-dev de6faa2): Downloading (100%)
  - Installing symfony/class-loader (3.4.x-dev 8c7ae3c): Downloading (100%)
  - Installing psr/simple-cache (dev-master 753fa59): Downloading (100%)
  - Installing psr/cache (dev-master 78c5a01): Downloading (100%)
  - Installing symfony/cache (3.4.x-dev a56a943): Downloading (100%)
  - Installing doctrine/cache (dev-master 0da649f): Downloading (100%)
  - Installing symfony/framework-bundle (3.4.x-dev d3053f4): Downloading (100%)
    Detected auto-configuration settings for "symfony/framework-bundle"
    Enabling the package as a Symfony bundle
  - Installing symfony/yaml (3.4.x-dev 19248c8): Downloading (100%)
  - Installing symfony/dotenv (3.4.x-dev c6eb017): Downloading (100%)
Writing lock file
Generating autoload files

> tree -La 2
.
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ .env.dist
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ composer.lock
โ”œโ”€โ”€ etc
โ”‚ย ย  โ””โ”€โ”€ bundles.php
โ””โ”€โ”€ vendor
    โ”œโ”€โ”€ autoload.php
    โ”œโ”€โ”€ composer
    โ”œโ”€โ”€ doctrine
    โ”œโ”€โ”€ psr
    โ””โ”€โ”€ symfony

Here, flex recipes have been applied.

All 9 comments

The reason is that the 3.4 branch has been created yesterday (meaning that 3.4.x-dev now is a valid version constraint) and there are no recipes for 3.4 yet (see symfony/recipes#69 for the fix).

@xabbuh I don't think the issue is related to what you mentioned.

Here is a composer.json you can try. It only requires symfony/flex.

{
    "type": "project",
    "minimum-stability": "dev",
    "require": {
        "php": "^7.1",
        "symfony/flex": "^1.0"
    },
    "require-dev": {
        "symfony/dotenv": "^3.3"
    },
    "config": {
        "platform": {
            "php": "7.1"
        },
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "scripts": {
        "auto-scripts": [
        ],
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "extra": {
        "symfony": {
            "id": "",
            "allow-contrib": false
        }
    }
}

Try to copy it and run composer install then remove everything except composer.json and run composer create-project.

Here is the difference:

> composer create-project
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing symfony/flex (dev-master 40c8b45): Loading from cache
    Detected auto-configuration settings for "symfony/flex"
    Setting configuration and copying files
  - Installing symfony/dotenv (3.4.x-dev c6eb017): Loading from cache
Writing lock file
Generating autoload files

> rm -rf .env* vendor composer.lock

> composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing symfony/flex (dev-master 40c8b45): Loading from cache
  - Installing symfony/dotenv (3.4.x-dev c6eb017): Loading from cache
Writing lock file
Generating autoload files

As you can see with composer install the flex scripts are not triggered at all.

Ok, I think in the case you manually run composer install, composer doesn't install the symfony/flex plugin before the other dependencies, as it does when running composer create-project. That's why the symfony/flex recipe cannot be applied with composer install. Any idea why create-project has such a different behaviour when installing dependencies?

The doc says though https://getcomposer.org/doc/03-cli.md#create-project :

This is the equivalent of doing a git clone/svn checkout followed by a "composer install" of the vendors.

Here are the steps I finally followed to make flex work from a custom composer.json file (I needed to do so to avoid this issue https://github.com/symfony/recipes/pull/69):

{
    "type": "project",
    "minimum-stability": "dev",
    "require": {
        "php": "^7.1",
        "symfony/flex": "^1.0@dev"
    },
    "config": {
        "platform": {
            "php": "7.1"
        },
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "scripts": {
        "auto-scripts": [],
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "extra": {
        "symfony": {
            "id": "",
            "allow-contrib": false
        }
    }
}
> composer create-project
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing symfony/flex (dev-master 40c8b45): Loading from cache
    Detected auto-configuration settings for "symfony/flex"
    Setting configuration and copying files
Writing lock file
Generating autoload files
> composer req symfony/framework-bundle "3.3.*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 19 installs, 0 updates, 0 removals
  - Installing symfony/stopwatch (3.4.x-dev 162ab93): Loading from cache
  - Installing symfony/routing (3.4.x-dev 6dbb39f): Loading from cache
  - Installing symfony/polyfill-mbstring (dev-master e79d363): Loading from cache
  - Installing psr/log (dev-master 4ebe3a8): Loading from cache
  - Installing symfony/debug (3.4.x-dev 627c397): Loading from cache
  - Installing symfony/http-foundation (3.4.x-dev 3e35088): Loading from cache
  - Installing symfony/event-dispatcher (3.4.x-dev dc71961): Loading from cache
  - Installing symfony/http-kernel (3.4.x-dev 755a852): Loading from cache
  - Installing symfony/finder (3.4.x-dev a90f2ad): Loading from cache
  - Installing symfony/filesystem (3.4.x-dev 45e8dd4): Loading from cache
  - Installing psr/container (dev-master b7ce3b1): Loading from cache
  - Installing symfony/dependency-injection (3.4.x-dev fee0f72): Loading from cache
  - Installing symfony/config (3.4.x-dev de6faa2): Loading from cache
  - Installing symfony/class-loader (3.4.x-dev 8c7ae3c): Loading from cache
  - Installing psr/simple-cache (dev-master 753fa59): Loading from cache
  - Installing psr/cache (dev-master 78c5a01): Loading from cache
  - Installing symfony/cache (3.4.x-dev a56a943): Loading from cache
  - Installing doctrine/cache (dev-master 0da649f): Loading from cache
  - Installing symfony/framework-bundle (3.3.x-dev 990ea5b): Loading from cache
    Detected auto-configuration settings for "symfony/framework-bundle"
    Enabling the package as a Symfony bundle
    Setting configuration and copying files
    Adding environment variable defaults
    Adding Makefile entries
    Adding entries to .gitignore
Writing lock file
Generating autoload files
Executing script make cache-warmup [OK]
Skipping "assets:install --symlink --relative web" (needs symfony/console to run).


 What's next?


  * Run your application:
    1. Change to the project directory
    2. Execute the make serve command;
    3. Browse to the http://localhost:8000/ URL.

  * Read the documentation at https://symfony.com/doc

the fact that the plugin is not applied in this case looks like a bug (either in flex or in composer)

Will be fixed soon, see symfony/recipes#70

Fixed and works well.

Real fix at #107

Hi,

I still have the same issue.
I have created symfony skeleton project using composer create-project command.

$ composer create-project symfony/skeleton:^3.3 demo
Installing symfony/skeleton (v3.3.2)
  - Installing symfony/skeleton (v3.3.2): Loading from cache
Created project in demo
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 23 installs, 0 updates, 0 removals
  - Installing symfony/flex (v1.0.20): Loading from cache
  - Installing symfony/stopwatch (v3.3.9): Loading from cache
  - Installing symfony/routing (v3.3.9): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.5.0): Loading from cache
  - Installing symfony/http-foundation (v3.3.9): Loading from cache
  - Installing symfony/event-dispatcher (v3.3.9): Loading from cache
  - Installing psr/log (1.0.2): Loading from cache
  - Installing symfony/debug (v3.3.9): Loading from cache
  - Installing symfony/http-kernel (v3.3.9): Loading from cache
  - Installing symfony/finder (v3.3.9): Loading from cache
  - Installing symfony/filesystem (v3.3.9): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/dependency-injection (v3.3.9): Loading from cache
  - Installing symfony/config (v3.3.9): Loading from cache
  - Installing symfony/class-loader (v3.3.9): Loading from cache
  - Installing symfony/polyfill-apcu (v1.5.0): Loading from cache
  - Installing psr/simple-cache (1.0.0): Loading from cache
  - Installing psr/cache (1.0.1): Loading from cache
  - Installing symfony/cache (v3.3.9): Loading from cache
  - Installing doctrine/cache (v1.7.1): Loading from cache
  - Installing symfony/framework-bundle (v3.3.9): Loading from cache
  - Installing symfony/yaml (v3.3.9): Loading from cache
  - Installing symfony/dotenv (v3.3.9): Loading from cache
Writing lock file
Generating autoload files
Symfony operations: 3 recipes
  - Configuring symfony/flex (1.0): From github.com/symfony/recipes:master
  - Configuring symfony/routing (3.3): From github.com/symfony/recipes:master
  - Configuring symfony/framework-bundle (3.3): From github.com/symfony/recipes:master
Executing script make cache-warmup [OK]
Skipping "assets:install --symlink --relative public" (needs symfony/console to run).


 What's next? 


  * Run your application:
    1. Change to the project directory
    2. Execute the make serve command;
    3. Browse to the http://localhost:8000/ URL.

  * Read the documentation at https://symfony.com/doc

I also installed symfony/console package:

$ composer req cli
Using version ^3.3 for symfony/console
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing symfony/console (v3.3.9): Loading from cache
Writing lock file
Generating autoload files
Symfony operations: 1 recipe
  - Configuring symfony/console (3.3): From github.com/symfony/recipes:master
Executing script make cache-warmup [OK]
Executing script assets:install --symlink --relative public [OK]

and all the recipes worked, all directories were created

โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ composer.lock
โ”œโ”€โ”€ config
โ”‚ย ย  โ”œโ”€โ”€ bundles.php
โ”‚ย ย  โ”œโ”€โ”€ packages
โ”‚ย ย  โ”œโ”€โ”€ routes.yaml
โ”‚ย ย  โ””โ”€โ”€ services.yaml
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ public
โ”‚ย ย  โ”œโ”€โ”€ bundles
โ”‚ย ย  โ””โ”€โ”€ index.php
โ”œโ”€โ”€ src
โ”‚ย ย  โ”œโ”€โ”€ Controller
โ”‚ย ย  โ””โ”€โ”€ Kernel.php
โ””โ”€โ”€ vendor
    โ”œโ”€โ”€ autoload.php
    โ”œโ”€โ”€ composer
    โ”œโ”€โ”€ doctrine
    โ”œโ”€โ”€ psr
    โ””โ”€โ”€ symfony

and then I committed this project to git repository using the default .gitignore file (which was created by composer and recipes) (composer.lock file was also committed). And now, when I clone this repo and run composer install command a recipes are no longer executed and directories are not created, scripts in the bin folder are not created

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 24 installs, 0 updates, 0 removals
  - Installing symfony/flex (v1.0.20): Loading from cache
  - Installing psr/cache (1.0.1): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing psr/simple-cache (1.0.0): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.5.0): Loading from cache
  - Installing psr/log (1.0.2): Loading from cache
  - Installing symfony/debug (v3.3.9): Loading from cache
  - Installing symfony/console (v3.3.9): Loading from cache
  - Installing symfony/stopwatch (v3.3.9): Loading from cache
  - Installing symfony/routing (v3.3.9): Loading from cache
  - Installing symfony/http-foundation (v3.3.9): Loading from cache
  - Installing symfony/event-dispatcher (v3.3.9): Loading from cache
  - Installing symfony/http-kernel (v3.3.9): Loading from cache
  - Installing symfony/finder (v3.3.9): Loading from cache
  - Installing symfony/filesystem (v3.3.9): Loading from cache
  - Installing symfony/dependency-injection (v3.3.9): Loading from cache
  - Installing symfony/config (v3.3.9): Loading from cache
  - Installing symfony/class-loader (v3.3.9): Loading from cache
  - Installing symfony/polyfill-apcu (v1.5.0): Loading from cache
  - Installing symfony/cache (v3.3.9): Loading from cache
  - Installing doctrine/cache (v1.7.1): Loading from cache
  - Installing symfony/framework-bundle (v3.3.9): Loading from cache
  - Installing symfony/yaml (v3.3.9): Loading from cache
  - Installing symfony/dotenv (v3.3.9): Loading from cache
Generating autoload files
Executing script make cache-warmup [OK]
Executing script assets:install --symlink --relative public [KO]
 [KO]
Script assets:install --symlink --relative %PUBLIC_DIR% returned with error code 1
!!  Could not open input file: bin/console
!!  
!!  

It looks like the flex plugin was not triggered.
After some attempts, I discovered that recipes are only triggered when I delete composer.lock file.

Composer version 1.5.2 2017-09-11 16:59:25
PHP 7.1.9

Flex recipes are only triggered when the package is newly installed (or is getting removed). So you need to commit the bin/console and config/bundles.php files in your version control.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

javiereguiluz picture javiereguiluz  ยท  6Comments

shyim picture shyim  ยท  5Comments

javiereguiluz picture javiereguiluz  ยท  6Comments

marcw picture marcw  ยท  4Comments

eb22fbb4 picture eb22fbb4  ยท  8Comments