diff --git a/.env b/.env index 861c6df..766bf28 100644 --- a/.env +++ b/.env @@ -20,10 +20,6 @@ APP_DEBUG=1 APP_SECRET=3bUhVCRkHJfT2ZJTqBnvkclRFT1zy1ig ###< symfony/framework-bundle ### -# To test the production environmet, run: -# > cp .env.local.dist .env.local -# > bin/console asset-map:compile +# To test the production environment, run "make go-prod" or "castor symfony:go-prod" -# To come back to the development environment, run: -# > rm .env.local -# > rm -rf ./public/assets/* \ No newline at end of file +# To come back to the development environment, run "make go-dev" or "castor symfony:go-dev" diff --git a/Makefile b/Makefile index 1746cb5..934ac31 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,16 @@ stop: ## Stop the web server @symfony server:stop +## —— Symfony 🎶 —————————————————————————————————————————————————————————————— +go-prod: ## Switch to the production environment + @cp .env.local.dist .env.local + @bin/console asset-map:compile + +go-dev: ## Switch to the development environment + @rm .env.local + @rm -rf ./public/assets/* + + ## —— Tests ✅ ————————————————————————————————————————————————————————————————— test: ## Run all PHPUnit tests @vendor/bin/simple-phpunit diff --git a/castor.php b/castor.php index fde72fc..905c334 100644 --- a/castor.php +++ b/castor.php @@ -43,6 +43,36 @@ function stop(): void success(); } +#[AsTask(namespace: 'symfony', description: 'Switch to the production environment')] +function go_prod(): void +{ + title(__FUNCTION__, get_command()); + if (io()->confirm('Are you sure you want to switch to the production environment? This will overwrite your .env.local file', false)) { + run('cp .env.local.dist .env.local', quiet: false); + run('bin/console asset-map:compile', quiet: false); + success(); + + return; + } + + io()->comment('Aborted.'); +} + +#[AsTask(namespace: 'symfony', description: 'Switch to the development environment')] +function go_dev(): void +{ + title(__FUNCTION__, get_command()); + if (io()->confirm('Are you sure you want to switch to the development environment? This will delete your .env.local file', false)) { + run('rm .env.local', quiet: false); + run('rm -rf ./public/assets/*', quiet: false); + success(); + + return; + } + + io()->comment('Aborted.'); +} + #[AsTask(name: 'all', namespace: 'test', description: 'Run all PHPUnit tests')] function test(): void {