Written by me@grafxflow
23 Dec, 2016
4
7,205
I had to recently update my version of Laravel 5.2 to Laravel 5.3 along with my php version to 7.1. It was a little bit tricky due to some missing help documentation, but I managed to figure it out. So if you are having the same problems then this should help.
WARNING: Don't ignore this since it's important! Now before doing anything I noticed a memory issue when installing and after searching around - it turned out to be the pragmarx -> tracker in the vendors folder. If you have installed this I would suggest you temporarily disable it while doing the update by changing the following file config/tracker.php and make this change 'enabled' => false.
This first part isn't really important since if you are running Laravel 5.2 then you should already be running the minimum version of PHP 5.6. But for me I decided to install PHP 7.1
So start by using terminal and enter the following.
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.1
It will also ask for your password before installing.
This could take a while but once done enter the next line to restart apache. And again it will ask for your password.
sudo /usr/sbin/apachectl restart
This restart should be instantaneous, so enter the following line to see which version of php is being used.
php -v
It should output the following...
PHP 7.1.0 (cli) (built: Dec 2 2016 09:19:56) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.1.0, Copyright (c) 1999-2016, by Zend Technologies
Now lets open the composer.json which is in the root folder and make the following changes.
"laravel/framework": "5.2.*",
to
"laravel/framework": "5.3.*",
and more importantly (without this change it wouldn't update for me) since I had installed the Laravel Forms and HTML components
"laravelcollective/html": "5.2.*",
to
"laravelcollective/html": "5.3.*",
and
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
to
"symfony/css-selector": "2.8.*|3.1.*",
"symfony/dom-crawler": "2.8.*|3.1.*"
Next edit the following lines of code in the app/Providers/RouteServiceProvider.php file.
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
to
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
Next edit the following lines of code in the app/Providers/EventServiceProvider.php file.
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
//
}
to
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
//
}
So what's the reason for editing to the 2 files in the Providers folder?
The answer being that if you were to run the update without doing this - the terminal will show the following error messages at the end of the installation.
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
[ErrorException]
Declaration of App\Providers\EventServiceProvider::boot(Illuminate\Contracts\Events\Dispatcher $events) should be compatible with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot()
Script php artisan optimize handling the post-update-cmd event returned with error code 1
Now we are going to do the update. So in the terminal use cd and enter the directory for this example something in MAMP folder.
cd /Applications/MAMP/htdocs/our-laravel-app
Then input this to start the Laravel 5.3 update.
php /Applications/MAMP/htdocs/composer.phar update
You should see the list of updates in the terminal.
So now lets check it has worked and in the terminal input
php artisan --version
It should now output
Laravel Framework version 5.3.28
So in theory everything should work fine? Read on...
After installing I tried the following code in the terminal to add the login author default controllers etc.
php artisan make:auth
But I would keep getting the following errors, or similar.
[ErrorException]
file_put_contents(/Applications/MAMP/htdocs/our-laravel-app/routes/web.php): failed to open stream: No such file or directory
Well it turns out there is a change in Laravel 5.3 with regard to the app/Http/routes.php file. It now uses a different folder and file structure. They are now in the same directory that contains the app folder for example routes/web.php
So the only workaround was to install a separate version of Laravel 5.3 using something like the following.
php composer.phar create-project laravel/laravel temp-laravel "5.3.*" --prefer-dist
Now copy the following into your updated version of Laravel 5.3.
routes/api.php
routes/console.php
routes/web.php
So now when inputting 'php artisan make:auth' it will work fine.
php artisan make:auth
Authentication scaffolding generated successfully.
I hope this has helped you with the update process from Laravel 5.2 to Laravel 5.3 and PHP 7.1.
07 Oct, 2016
26 Apr, 2018
08 Nov, 2012
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!
Follow11 Jul, 2023
21 Jun, 2023
Views: 166,096
Views: 40,208
Views: 36,920
Views: 33,515
4 Response
Farghana Hussain
23 Apr 2017
I keep getting this error:
laravel/framework v5.3.0 requires paragonie/random_compat ~1.4|~2.0 -> no matching package found.
Can you help please?
me@grafxflow
23 Apr 2017
Unsure what could be causing it.
Try:
php composer.phar require paragonie/random_compat
Or maybe try changing your php version if possible.
Also do you have any more information - is this a standalone install or an update.
Farghana Hussain
25 Apr 2017
I was trying to upgrade 5.2 to 5.3. However, I have installed a fresh version of Laravel 5.3 and all seems fine. I think there was some cache issue and I had to manually delete the cache files.
Anyways, thanks a lot for your response.
me@grafxflow
25 Apr 2017
Glad to hear you got it working.
Just need to try 5.4 now :)