-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Check laravel version before symlink storage #1246
Check laravel version before symlink storage #1246
Conversation
Since Laravel 5.2 does not have `artisan storage:link` command, we can't call it.
recipe/laravel.php
Outdated
@@ -105,7 +105,20 @@ | |||
|
|||
desc('Execute artisan storage:link'); | |||
task('artisan:storage:link', function () { | |||
run('{{bin/php}} {{release_path}}/artisan storage:link'); | |||
if (get('laravel_version') > 5.2) { |
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.
Use version-compare
http://php.net/manual/ru/function.version-compare.php
recipe/laravel.php
Outdated
}); | ||
|
||
desc('Get Laravel version'); | ||
task('artisan:version', 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.
Better define a as callback:
set('laravel_version', function () {
...
});
@antonmedv done, man. :) |
CHANGELOG.md
Outdated
@@ -5,6 +5,8 @@ | |||
|
|||
### Fixed | |||
- Fixed upload / download with optional rsync ssh options [#1227] | |||
- Fixed storage link error when deploying Laravel < 5.3. | |||
- Helps [#1153] |
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 is helps?) Add link also in bottom of document.
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.
@antonmedv this PR helps that issue. Sure, I will do that.
recipe/laravel.php
Outdated
|
||
$version = $matches[1][0] ?? 5.4; | ||
|
||
return (float) $version; |
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.
version_compare expects a string, no need to cast to float. Can only cause rounding errors.
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.
@barryvdh maybe I can change the regex to return the right version, but I did this because 5.2.13
> 5.2
, so we can get a false positive. What do you think?
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.
See the docs on http://php.net/manual/en/function.version-compare.php
That is specifically created to handle those situations.
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.
See https://3v4l.org/a0jb5 for examples
recipe/laravel.php
Outdated
set('laravel_version', function () { | ||
$result = run('{{bin/php}} {{release_path}}/artisan --version'); | ||
|
||
preg_match_all('/version\ (.+?)$/', $result, $matches); |
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.
Where does 'version' come from? My result is Laravel Framework 5.4.12
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.
@barryvdh hmmm. Make sense! In Laravel 5.2, --version
param come with 'version' string. I will change it. Thanks.
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.
Laravel 4: Laravel Framework version 4.2.22
Laravel 5.1: Laravel Framework version 5.1.35 (LTS)
Laravel 5.2: Laravel Framework version 5.2.45
Laravel 5.3: Laravel Framework version 5.3.30
Laravel 5.4: Laravel Framework 5.4.22
Lumen: Laravel Framework version Lumen (5.1.7) (Laravel Components 5.1.*)
Something like this? ([0-9.]+)
http://regexr.com/3g2ep
And please rebase. |
recipe/laravel.php
Outdated
@@ -105,7 +115,9 @@ | |||
|
|||
desc('Execute artisan storage:link'); | |||
task('artisan:storage:link', function () { | |||
run('{{bin/php}} {{release_path}}/artisan storage:link'); | |||
if (version_compare(get('laravel_version'), 5.2, '>')) { |
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 as you say in the docs, you want to check if the version is >= 5.3
or NOT < 5.3
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.
@barryvdh sure sure! You are right! I will do the changes. Thanks, man!
@antonmedv @barryvdh can you check please? :) |
@lucasmezencio nice work! |
set('laravel_version', function () { | ||
$result = run('{{bin/php}} {{release_path}}/artisan --version'); | ||
|
||
preg_match_all('/([0-9\.])$/', $result, $matches); |
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.
Wrong, should be '/([0-9.]+)/'
. You want to match ALL numbers/dots, not just 1. And it doesn't have to match the end of string.
Since Laravel 5.2 doesn't have
artisan storage:link
command, we can't call on versions below5.3
.