-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Symfony flex support #1440
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
Conversation
zorn-v
commented
Dec 8, 2017
Q | A |
---|---|
Bug fix? | No |
New feature? | Yes |
BC breaks? | No |
Deprecations? | No |
Fixed tickets | #1437 |
6df4be4
to
6be861c
Compare
6be861c
to
976de9a
Compare
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Also nope. var/log
, not var/logs
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.
The default directory for logs is var/log
(since 3.4)
set('shared_dirs', ['var/log', 'var/sessions']); | ||
|
||
// 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Also var/log
recipe/symfony-flex.php
Outdated
// Environment vars | ||
set('env', function () { | ||
return [ | ||
'APP_ENV' => get('symfony_env') |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Before it was SYMFONY_ENV
https://github.com/deployphp/deployer/blob/master/recipe/symfony.php#L41
But it not for flex
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I can not set environment variables on my server so Dotenv
is also included in the production environment. There were complications. I noticed that setting APP_ENV
disables reading the .env file, therefore I set only symfony_env
to have all commands with --env={{symfony_env}}
option. My env
for now:
// Environment vars
set('env', []);
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.
Hmm. Maybe you are right and your solution is much better than my hacky workaround #1440 (comment)
AFAIR composer does not account --env=
Will test, and change it if all works fine.
*/ | ||
|
||
//No need to clear anything | ||
set('clear_paths', []); |
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.
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 !
set('writable_dirs', ['var/cache', 'var/log', 'var/sessions']); | ||
|
||
//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 comment
The 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 comment
The 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
Another tought : what about commands launched that require DB access (in prod mode) ? 🤔 |
And now think about is it ENV vars really good for deploy ? |
@zorn-v no, then don't. 😄 I really want to combine all symfony recipes into one in next v7. Let's merge it now for v6 although. Can you add init script for symfony flex? |
What do you mean by 'init script' ? |
Yes, I already understand what do you mean 😄 "Best practice" (env vars) not so conveniently... You need to set params in 3 different places.
|
Let's leave it for user? 😁 Trim every thing related of setting params from recipe and add comment to init template about for to start using I like |
2795f09
to
06b888a
Compare
What do you think ? |
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 comment
The 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 comment
The 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
Same in console commands
But it need for composer install
(scripts can not load deps in require-dev if APP_ENV not 'prod')
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
But this task needed exactly in order if DotEnv in require ;)
One more time - DotEnv does not run if APP_ENV is set.
If you don't set it in env, composer install
will fail.
Yes I know that is hack. But I think that I can not convince community to change !isset($_SERVER['APP_ENV'])
to file_exists(__DIR__.'/../.env')
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 comment
The reason will be displayed to describe this comment to others. Learn more.
set('assets', ['{{web_dir}}/css', '{{web_dir}}/images', '{{web_dir}}/js']);
Okay, problem now with:
I think we just need mention not to refactor to:
|
Any news on this ? |
Need to figure out how to properly handle env. Soon will create my recipe. |
Any news, suggestions. Maybe need some recomendations ? |
In last project I just installed apache-pack and put SetEnv in .htaccess (with preg_replace with same vars for DB in deployer) |
I’m thinking on suggesting of using doyens for prod. This will require APP_ENV rrmoval |
Done in 443de26 |
Maybe |
|
|
About |
But you should set |
Yep, but I talk about default one. |
No, but chown may require sudo. acl no. And acl more flexible. But I'm thinking to refactor it in v7. |
Will there be a 6.0.1 ? for the missing |
Yes :) |
Don't be sorry ! You do an amazing work ! We can still add it ourself :D |