Repository navigation
v2.5.0
Important
The .env files are now loaded as in Symfony, with symfony/dotenv, and only from config/. Applications created from an earlier skeleton keep working until they update config/core.php; see the migration steps below.
.env files loaded as in Symfony (PR #34)
config/core.phploads the.envfiles with one line,(new Dotenv())->usePutenv()->bootEnv(CONFIG . '.env')(symfony/dotenv), instead of josegonzalez/dotenv.- Files, all in
config/, merged in this order (a later file wins, real environment variables win over all files):config/.env: committed defaults of the application (APP_ENV=dev)config/.env.local: values of one machine and secrets (ignored by Git; not loaded whenAPP_ENV=test)config/.env.{APP_ENV}, e.g.config/.env.test: committed values of an environmentconfig/.env.{APP_ENV}.local: values of one machine for that environment (ignored by Git)
- The root
.envis no longer read, andconfig/.env.exampleis gone:config/.envitself is committed with the defaults..gitignoreignores onlyconfig/.env.local,config/.env.local.phpandconfig/.env.*.local. APP_ENVcomes from the real environment, else from the files, and defaults todev.vendor/bin/phpunit,bin/cake testandwebroot/test.phprun withAPP_ENV=test.DEBUGdefaults to0whenAPP_ENV=prodand to2otherwise; an explicitDEBUGwins. In production, setAPP_ENV=prod.config/.env.testholds only what the tests change (DATABASE_URL,MAILER_DSN).- Real environment variables now also win in the web server of the End-to-End tests (pieceofcake2/panther): the previous loader could write a
.envvalue into$_ENVnext to a different real value.
Dependencies
- New:
symfony/dotenv^5.4 || ^6.4 || ^7.0 || ^8.0(PHP 8.0 gets 5.4; symfony/dotenv 8 needs PHP 8.4.1). Removed:josegonzalez/dotenv. - Requires
pieceofcake2/cakephp^2.12.7(unchanged). Dev:pieceofcake2/phpstan-cakephp2^1.0.
Migrating from an earlier skeleton
composer remove josegonzalez/dotenvandcomposer require symfony/dotenv.- Replace the
.envloading at the top ofconfig/core.phpwith:and the debug line withuse Symfony\Component\Dotenv\Dotenv; (new Dotenv())->usePutenv()->bootEnv(CONFIG . '.env');
Configure::write('debug', env('DEBUG') ?? (env('APP_DEBUG') ? 2 : 0));. - Move a root
.envtoconfig/. Commitconfig/.envwith the defaults andAPP_ENV=dev, and move the values of your machine and the secrets toconfig/.env.local. - Keep only what the tests change in
config/.env.test, and only what differs on your machine inconfig/.env.test.local(the files are merged now). - In
.gitignore, ignore/config/.env.local,/config/.env.local.phpand/config/.env.*.localinstead ofconfig/.envand the root.envfiles. - In production, set
APP_ENV=prodand the other settings as real environment variables.
See Environment Variables in the documentation.
Installation
composer create-project pieceofcake2/app my_appFull Changelog: v2.4.3...v2.5.0