Categories
Laravel

Using Laravel Shift For The First Time

This is a list of useful steps to follow when upgrading Laravel using shift:

General Helpful Notes:

– Our first priority is to get Laravel onto the new version, and then work out the errors from there. If a package or dependency is erroring out take note of the package, then delete it from composer.json. Once the new version of Laravel fully installs, then add the packages one at a time by typing:

composer require package-name

If you get an error when running the above telling you that a higher version of the package is needed, then type:

composer require ^version# package-name

– Alt + Enter in PHPStorm will add a missing class to your file automatically. Super useful!

– At time we might need to copy an entire file from the new version of Laravel into our project. When we do this a handy tip is that PHPstorm will highlight on the left hand side any sections where the file has changed. You can go to this individual line ant hit Control + Alt + Z and that single line will revert to the previous copy allowing you to see the differences.

Step By Step Notes:

1.) Create a new release branch from master, name the branch something like “upgrade”.

2.) Purchase the shift you want, and have it performed on the upgrade branch.

3.) Review all pull request comments for additional changes, install Larave (deleting dependencies/packages as needed and keeping them in a list to add back later). Run “composer update” (if the pre-scripts fail, add –no-scripts)

4.) Now we are ready to fire up our application and check for any errors. Starting in Laravel 5.2 artisan serve is deprecated and you need to instead use:
php -S localhost:8080 -t public/

Testing & Error Code Notes:

1.) If you see the error message:
Access level to Illuminate\Routing\Router::substituteImplicitBindings() must be public (as in class Illuminate\Contracts\Routing\Registrar) in C:\wamp64\www\vendor\laravel\framework\src\Illuminate\Routing\Router.php on line 21

The fix for this is to find where this is being called and set it to public. To find in PHPStorm open up find in path (Control + Shift + F). Select whole project and then search for substituteBindings. In our case this is pulling up in our router.php file. Sure enough substitute bindings was set to protected, we change it to public and our error is resolved.

2.) If you see the error message:
Uncaught ReflectionException: Class log does not exist in

The fix for this is to open up your .env file and make sure that all of your values are enclosed in quotes. So for example starting from the top your values should look like: APP_ENV="local"

3.) If you see the error:
Class 'Illuminate\Html\HtmlServiceProvider' not found

The fix for this is:

Add this to your composer.json file:
"require": {
"laravelcollective/html": "5.1.*"
}

Run composer update

Add the following to your providers array in config/app.php

'providers' => [
Collective\Html\HtmlServiceProvider::class,
],

Add the aliases to the aliases array of config/app.php
'aliases' => [
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
],

Run composer dump-autoload -o
Run composer update

**make sure to run composer update before adding the service provider or else you will get the error:
Class 'Collective\Html\HtmlServiceProvider::class' not found

4.) If you see the error:

FatalErrorException in Paginator.php line 15:
Declaration of Illuminate\Pagination\Paginator::render(?Illuminate\Contracts\Pagination\Presenter $presenter = NULL) must be compatible with Illuminate\Contracts\Pagination\Paginator::render($view = NULL)

The fix for this we need to delete the current vendor folder then run composer install