How does circleci-demo-php-laravel prepare APP_KEY without creating .env file?

I am currently setting up CI for my Laravel project.
I refer the demo repository above to know how to make it but I can not understand why demo’s jobs success on Circle CI.

php artisan clear-compiled

The compiled services file has been removed.

php artisan optimize

Generating optimized class loader
The compiled services file has been removed.

https://circleci.com/gh/CircleCI-Public/circleci-demo-php-laravel/46

They run php artisan clear-compiled and php artisan optimize on composer install -n --prefer-dist part.
These commands require APP_KEY on .env file but I don’t think there is .env file.
Their .circleci/config.yml ( https://github.com/CircleCI-Public/circleci-demo-php-laravel/blob/circleci-2.0/.circleci/config.yml ) does not prepare .env file on my understanding.

"post-create-project-cmd": [
  "php -r \"copy('.env.example', '.env');\"",
  "php artisan key:generate"
]

ttps://github.com/CircleCI-Public/circleci-demo-php-laravel/blob/circleci-2.0/composer.json#L38-L41

There is "php -r \"copy('.env.example', '.env');\"", on compose.json but that is post-create-project-cmd.
Circle CI job checkouts the source code but not creates the project.
So I think this does not affect that jobs succeed.

How does circleci-demo-php-laravel prepare APP_KEY without creating .env file or does it create .env file?

Notice how the demo project has an .env.testing file checked into the root of the repo with the APP_KEY already generated. This is the best practice per the laravel docs. You should do something similar in your own project.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.