New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symfony flex support #1440
Symfony flex support #1440
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Deployer; | ||
|
||
require_once __DIR__ . '/symfony3.php'; | ||
|
||
/** | ||
* Symfony Flex Configuration | ||
*/ | ||
|
||
//No need to clear anything | ||
set('clear_paths', []); | ||
|
||
// Symfony shared dirs | ||
set('shared_dirs', ['var/log', 'var/sessions']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also nope. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default directory for logs is |
||
|
||
// Symfony writable dirs | ||
set('writable_dirs', ['var/cache', 'var/log', 'var/sessions']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also |
||
|
||
//File for DotEnv if not using env vars | ||
set('shared_files', ['.env']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And btw the dotenv component is in require-dev when we do a fresh install ... I'm not sure if it's a good idea There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually there is a conversation on moving dotenv to require symfony/symfony#25643 |
||
|
||
// Symfony web dir | ||
set('web_dir', 'public'); | ||
|
||
// Assets | ||
set('assets', ['public/css', 'public/images', 'public/js']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set('assets', ['{{web_dir}}/css', '{{web_dir}}/images', '{{web_dir}}/js']); |
||
|
||
// Environment vars | ||
set('env', function () { | ||
return [ | ||
'APP_ENV' => get('symfony_env') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably add documentation to tell the user to put "symfony_env" in it's host.yml There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before it was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe: // Environment vars
set('env', function () {
return [
'SYMFONY_ENV' => get('symfony_env'),
'APP_ENV' => get('symfony_env'),
];
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can not set environment variables on my server so // Environment vars
set('env', []); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Maybe you are right and your solution is much better than my hacky workaround #1440 (comment) |
||
]; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/* (c) github.com/zorn-v | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Deployer\Initializer\Template; | ||
|
||
/** | ||
* Generate a Symfony flex deployer configuration. | ||
* | ||
* @author zorn-v | ||
* @codeCoverageIgnore | ||
*/ | ||
class SymfonyFlexTemplate extends FrameworkTemplate | ||
{ | ||
protected function getRecipe() | ||
{ | ||
return 'symfony-flex'; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function getExtraContent() | ||
{ | ||
return <<<PHP | ||
|
||
// Migrate database before symlink new release. | ||
|
||
before('deploy:symlink', 'database:migrate'); | ||
|
||
//If you don't use DotEnv in prod just wipe it out | ||
task('clear:env', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What purpose of this task? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DotEnv does not run at all if APP_ENV is set https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php#L11 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better not to hack APP_ENV but unstead write comment what user need to move dotenv to require section. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this task needed exactly in order if DotEnv in require ;) Yes I know that is hack. But I think that I can not convince community to change |
||
//DotEnt does not execute if APP_ENV is set, but it required for `composer install` | ||
\$env = get('env'); | ||
unset(\$env['APP_ENV']); | ||
set('env', \$env); | ||
})->setPrivate(); | ||
after('deploy:vendors', 'clear:env'); | ||
PHP; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already define in symfony3 recipe :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope https://github.com/deployphp/deployer/blob/master/recipe/symfony.php#L30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad ! Sorry !