In App -> Http -> Kernel.php line 22 we will comment out this:
/* comment this out because its causing errors anytime someone submits a form with an empty value
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
end comment */
Second Error:
Once on Laravel 6.0 we needed to jump our version of php because the site would not load with our old version of php 7.2 running. We asked valet to use @php7.4 which caused this error message:
Brew was unable to install [php@7.4]
To Fix:
brew update
brew upgrade php
composer global update
valet install
valet use php@7.4
composer global update
*note if the latest version of valet did not come installed with support for php 7.4 (it did, but if it didn’t) then we could have edited this file:
code ~/.composer/vendor/laravel/valet/cli/Valet/Brew.php
class Brew
{
const SUPPORTED_PHP_VERSIONS = [
'php',
'php@7.4',
'php@7.3',
'php@7.2',
'php@7.1',
'php@7.0',
'php@5.6',
'php73',
'php72',
'php71',
'php70',
'php56'
];
*just add php 7.4 to the top of the list, or whatever version of php you need valet to support.
First Error On Staging Site:
When trying to submit a form we get this error message of “undefined index:secret”
Fix:
Double check that the file config -> services.php has the SparkPost varialbes setup correctly, they should be:
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
// optional guzzle specific configuration
'guzzle' => [
'verify' => true,
'decode_content' => true,
],
'options' => [
// configure endpoint, if not default
'endpoint' => env('SPARKPOST_ENDPOINT'),
// optional Sparkpost API options go here
'return_path' => 'SendingEmail@verifieddomain.com',
'options' => [
'open_tracking' => false,
'click_tracking' => false,
'transactional' => true,
],
],
],
This post is going to go through upgrading a site currently running Laravel 5.6. We will be taking the site up from 5.6 to 5.7 with the goal of eventually going all the way to 6.0 (the latest LTS at the time of this writing).
Start by creating a new upgrade branch from the dev branch:
git checkout -b feature/upgrading-laravel dev
*please note we are pulling from the dev branch here because the dev branch is currently more up to date than the master branch. We are writing these Laravel upgrades during a single day upgrade process, taking a Laravel site from 5.5 all the way up to 6.0. So if you are following along this series updating your own site make sure to branch off of whatever your current branch is (which will most likely be master)
The next thing we are going to do is open up sourcetree and push our newly created feature branch up to the remote repo server. To do this we will hit the push button and then check the box for the new branch and hit push.
Now that we have our new feature branch to the remote repo, were going to login to Laravel shift and purchase the shift we need, in this case we will be purchasing a shift from 5.6 -> 5.7. When we purchase the shift we will input our new feature branch as the branch shift should use to update from. In the Shift Screen there will be 2 boxes and we will need to fill them in this:
username/repo-name branch-name
With our shift purchased and executed, its time to merge the new branch shift creates into our updating branch and check how the site is doing locally:
Before we view the site locally we will also want to run:
composer update
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:clear
Issues with cache:clear:
*If the artisan cache:clear line fails due to permissions issue, then do the following to fix that error:
Check to see if the data folder is present at:
storage/framework/cache/data
Create the data directory manually if its not there: (storage/framework/cache/data)
run php artisan route:clear again and it should work :)
--update --
If creating the data folder still does not fix the issue, then try running:
php artisan config:cache
If there are any bugs we will fix those, in this case we did not have any issues so we will go ahead and merge our branch into the dev branch and test it on the staging server.
git checkout dev
git merge --no-ff feature/upgrading-laravel -m "merge laravel 5.7 into dev"
*we can either then git push dev from the command line, or we can use sourcetree to push the dev branch up to the remote server, and deploy to the staging site from there.
Once logged into our staging server we will run our deployment script, and then navigate to the project root folder and run the following commands:
*one special note, if the server has any issue running composer update, we can always delete the vendor directory and then run composer install which will install a fresh version of all dependencies. The fastest way to delete the vendor folder is via command line with:
rm -rf vendor
Fixing Issues:
#1: A Note From Shift: Laravel 5.8 changed several of the core contracts with new implementations and methods. You should review the Upgrade Guide for more detail on these respective changes:
In CustomFormBuilderServiceProvider.php line 9:
Interface 'Illuminate\Contracts\Support\DeferrableProvider' not found
In CustomFormBuilderServiceProvider.php line 9:
Interface 'Illuminate\Contracts\Support\DeferrableProvider' not found
To fix this issue we just updated the packages in composer.json to work with the latest version of Laravel. This was tricky as composer was not able to resolve the packages into an installable set, so what we did is removed all of the packages and then added them back into the file in small chunks and ran composer each time, until we arrived at the full set of needed packages.
Error #2:
The file TrustProxies.php was causing an error message to display in the command line, to fix this we changed the code in this file to:
The latest version of Laravel needs these values to be explicitly defined.
Error #4
Once we try to login to the site we are getting the error:
To fix this we will update our call in AuthAdminiter.php to be:
$this->authenticate($request, $guards);
Error #5
Once we got the login permission issue fixed, we were then presented with this error screen:
If we look at the error we can pull out a few clues:
Missing required parameters for [Route: packages.create_for_vehicle]
[URI: manage/packages/create/vehicle={vehicle_id}].
(View:C:\wamp64\www\SFPS\resources\views\vehicles\partials\table.blade.php)
The route mentioned in the error wants you to pass vehicle_id, but the code as-is is only passing in id so Laravel can’t figure that out. To fix this we can either rename it, or remove the special key. ([$vehicle->id] or [‘vehicle_id’=>$vehicle->id]). So in our case we made the following update to fix the bug:
It looks like Laravel dropped support for SparkPost around 5.8 – so we are now getting these errors on all of our form submissions:
This package was giving us some issues when installing, in order to successfully install it we had to remove the 4.0 version that installed automatically with the package and instead install version 2.0 using the code below::
When we did this we ran into an issue that Guzzle 7.0 was not compatible with V2.0 of the SparkPost Package and could not install correctly as well, so to fix that we ran:
Once that package is installed its important to note that we also need to then run:
php artisan config:clear
php artisan cache:clear
The above gets the site working on our local machine, however when we deploy to the staging site we are still running into a different error screen which we will fix under Error #8 below, but first a general note.
General Error – Error #7
If you are getting the php memory limit error when running composer install or update, which looks like this:
To work around this issue run the code below, which tells PHP to keep trying instead of stopping after reaching the initial memory limit set on the server
composer_memory_limit=-1 composer install
Error #8:
On the staging server we are getting the error that allow_url_fopen must be enabled in php.ini. We login to cpanel and set this to enabled, but we still receive this message. So we will manually run the command below instead, which allows url_fopen for this 1 single command:
which composer
//for us this spits out /opt/cpanel/composer/bin/composer so we will then run
php -d allow_url_fopen=on /opt/cpanel/composer/bin/composer install
Error 9:
With the SparkPost API now working, we are getting the error below:
Client error: `POST https://api.sparkpost.com/api/v1/transmissions` resulted in a `400 Bad Request` response:
{\"errors\":[{\"message\":\"Unconfigured Sending Domain <example.com>
To fix this error we will open up config/mail.php and change the backup email address from hello@example.com to the actual address we want to use:
So we ran into a little bit of an issue today when upgrading Laravel from 5.6 -> 6.0. We updated the version of PHP using the MultiPHP Manager section in Cpanel, however when we then SSH’d into the server to pull in the updated Laravel code and run composer install we ran into the issue of composer using the system version of PHP. The full process we went through is below:
Update the version of PHP on MultiPHP manager page:
composer install
We instead ran:
~/bin/composer install
Composer now uses the version of PHP defined in the shim script, which in our case is PHP 7.3 and we are back to all green happy lines π
$this->wheres[] = compact('type', 'operator', 'query', 'boolean');
you just remove the 'operator' parameter
Please note this is just a temporary fix to remove the error page. The long term fix for this is that the version of Laravel will need to be updated, and then composer update needs to be run to pull in the latest packages that will work with the new version of Laravel, and they will handle the new behavior of the compact method. The old version allowed for empty variables to be passed to the compact method, but in PHP 7.3 if an empty variable is passed to the compact method it presents you with that nice error message π