I want to Upgrade my Laravel project from (5.5 to 8) what I will do for that.
I didn't found any documents to upgrade from 5.5 to 8 just upgrade from 5.5 to 5.6 or from 7 to 8 maybe must upgrade the project step by step from 5.5 to 5.6 the from 5.6 to 5.7 then .... nutil 8
Thanks
composer.json(Laravel 5.5):
{
"name": "HomFolio",
"description": "Smart Property Investing",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"ext-json": "*",
"barryvdh/laravel-dompdf": "^0.8.1",
"barryvdh/laravel-translation-manager": "dev-master",
"fideloper/proxy": "~3.3",
"intervention/image": "^2.4",
"joedixon/laravel-translation": "^1.1",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"stripe/stripe-php": "^4.7",
"zizaco/entrust": "dev-master"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0",
"xethron/migrations-generator": "^2.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
composer.json (Laravel 8):
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0"
},
"require-dev": {
"facade/ignition": "^2.0",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
Looks like upgrades are sequential. As of today, I have a laravel 5.7 project that I have to upgrade to Laravel 8 and this looks like the sequence I need to take.
Even when you opt for the highly recommended Laravel Shift, you have to pay for each upgrade as indicated in the picture below.
.
If you have budget, laravel shift looks like a quick and easy way to go through the upgrade(s)
You have to follow the steps given below:
Copy the your current composer.json file.
Now go here https://github.com/laravel-shift/laravel-8.x/blob/master/composer.json and copy composer.json file and replace with your existing composer.json file.
Again go to https://github.com/laravel-shift/laravel-8.x/blob/master/app/Exceptions/Handler.php and copy the Handler.php file and go to app/exceptions/Handler.php replace Handler.php with your existing file.
Run the command composer update.
Check your old or your copied composer.json file and if packages have been added to it then you can add packages through this command composer require <package name>.
Now, again run composer update command.
You going to have to upgrade iteratively I'm afraid.
If you have the budget, you can use a service like Laravel Shift
to automate the upgrade.
Adding to some missing steps to #Krina Mangukiya
/bootstrap/environment.php :
$dotenv = Dotenv\Dotenv::createImmutable(DIR.'/..');
$dotenv->load();
The report and render methods of your application's
App\Exceptions\Handler class should accept instances of the Throwable
interface instead of Exception instances:
use Throwable;
public function report(Throwable $exception); public function
render($request, Throwable $exception);
This answers have taken from stackoverflow only but would be go to have all issue answers in one place.
Related
Actually Im trying to set API for my website on Laravel. I found that I need to add CreateFreshApiToken to Kernel.php in order to use it. Well, I wish could, but it doesn't exist. Then I have found I can get it via
composer require laravel/passport
I run it and have this one
composer require laravel/passport
./composer.json has been updated
Running composer update laravel/passport
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- artogrig/laravel-make-service[1.0.0, ..., 1.0.1] require illuminate/support ~5 -> found illuminate/support[v5.0.0, ..., 5.8.x-dev] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires artogrig/laravel-make-service ^1.0 -> satisfiable by artogrig/laravel-make-service[1.0.0, 1.0.1].
This is my comsposer.json:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5",
"artogrig/laravel-make-service": "^1.0",
"cviebrock/eloquent-sluggable": "^7.0",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"intervention/image": "^2.5",
"laravel/framework": "^7.0",
"laravel/passport": "^4.0",
"laravel/socialite": "^3.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0",
"tcg/voyager": "^1.4"
},
"require-dev": {
"facade/ignition": "^2.0",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"repositories": {
"hooks": {
"type": "composer",
"url": "https://larapack.io"
}
}
}
I have no idea what to do with. Could someone help me, please!
Thanks!
The dependency artogrig/laravel-make-service only works with Illuminate\Support 5, for what this package does, create service classes and is unmaintained. I would simply just remove it and your dependencies would be fixed.
I have recently upgraded Laravel in the project from 5.8.* to 6.x version.
Now when I try running command composer dump-autoload -o, I get this error:
Declaration of App\Exceptions\Handler::renderHttpException(Symfony\Component\HttpKernel\Exception\HttpException $e)
should be compatible with Illuminate\Foundation\Exceptions\Handler::renderHttpException(Symfony\Component\HttpKern
el\Exception\HttpExceptionInterface $e)
Below is the composer.json set in the project, when I upgraded Laravel from 5.7.* to 5.8.*, then also I got this same error as above, but I upgraded further hoping that would fix the issue:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"repositories": [
{
"type": "composer",
"url": "https://packages.[company_api].com"
}
],
"require": {
"php": ">=7.1.3",
"basemkhirat/elasticsearch": "^1.3",
"botman/botman": "^2.5",
"botman/driver-web": "^1.5",
"deployer/deployer": "^6.0",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"jenssegers/agent": "^2.6",
"jimmiw/php-time-ago": "^2.0",
"laravel/framework": "^6.0",
"laravel/scout": "^8.0",
"laravel/tinker": "~1.0",
"[company_name]/wordpressblogapi": "1.4.*"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~7.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"helpers/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
I have referred the docs and it doesn't specifically say about any Exception or Handler.php file changes, so anyone do suggest how to resolve this...
This is a 5.7 to 5.8 upgrade issue, as you point out when the problem started. The signature of that method changed:
"The renderHttpException method signature of the Illuminate\Foundation\Exceptions\Handler class has changed. If you are overriding this method in your exception handler, you should update the method signature to match its parent:"
/**
* Render the given HttpException.
*
* #param \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $e
* #return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpExceptionInterface $e);
Laravel 5.8 Docs - Upgrade Guide - Exception Handling
Hi I have a problem in laravel version 7
When i run Laravel in localhost, every thing is OK but when i run in Cpanel i get this error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Illuminate\Routing\RouteFileRegistrar::register(): Failed opening required '????/laravelPortal/routes/Api.php' (include_path='.:/opt/cpanel/ea-php72/root/usr/share/pear')
To make sure the files are loaded so i tested other Laravel sample in this location and it was true work also i remove all of routes file but i get Same above Error
Route::group(['prefix' => 'user'], function () {
Route::post('login', 'Api\UserController#login');
Route::post('register', 'Api\UserController#register');
Route::get('getUser/{id}', 'Api\UserController#getUser')->middleware(['auth:api','scopes:admin,user']);
Route::get('getUser', 'Api\UserController#getUser');
Route::get('logout', 'Api\UserController#logout') ->middleware(['auth:api','scope:admin,user']);
Route::get('checkAdmin', 'Api\UserController#checkAdmin')->middleware(['auth:api','scope:admin']);
});
my composer :
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/passport": "7.5.1",
"laravel/tinker": "^1.0",
"morilog/jalali": "3.*",
"shetabit/payment": "^2.1"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
i had the same issue with linux,it was a kind of case sensitive issue from my end,
i corrected the filename and file and that solved my issue
You can try this
Route::prefix('user')->group(function () {Your routes here});
I am testing pusher in my laravel lumen but i get an error with Pusher\Pusher:
I have already tried adding an alias for it and registering it but still no luck:
$app->alias('Pusher', Pusher\Pusher::class);
$app->register(Pusher\Pusher::class);
i have also deleted my vendor folder and reintalled my composer dependencies.
see below for my composer.json
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.2",
"appzcoder/lumen-routes-list": "^1.1",
"dusterio/lumen-passport": "^0.2.15",
"google/cloud-text-to-speech": "^0.5.0",
"guzzlehttp/guzzle": "~5.3|~6.0",
"illuminate/mail": "6.0",
"illuminate/redis": "^6.2",
"laravel/lumen-framework": "^6.0",
"laravelista/lumen-vendor-publish": "6.0",
"league/flysystem": "^1.0",
"predis/predis": "^1.1",
"pusher/pusher-php-server": "~2.0",
"smalot/pdfparser": "^0.14.0",
"superbalist/flysystem-google-storage": "^7.2",
"superbalist/laravel-google-cloud-storage": "^2.2"
},
"require-dev": {
"fzaninotto/faker": "^1.4",
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
You need to upgrade pusher/pusher-php-server sdk package version 3 or later. Pusher PHP sdk use namespace from version 3. To learn more visit their GitHub repo
I have forked a repo and created a branch called 3.0 that I would like to install to my project to test (not a longterm fork. I want to create a pull request after testing). I have added the following to my composer file:
"repositories": [{
"type": "vcs",
"url": "https://github.com/albertski/laravel-grid"
}],
When running composer show "albertski/laravel-grid" I get Package albertski/laravel-grid not found.
When I run composer require albertski/laravel-grid:3
.0-dev I get the following:
Could not find a matching version of package albertski/laravel-grid. Check
the package spelling, your version constraint and that the package is avail
able in a stability which matches your minimum-stability (dev).
Am I missing any steps? According to the docs that should be it. I am using Composer version 1.9.0.
This is my full composer.json file:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"laravel/browser-kit-testing": "^5.1",
"laravel/framework": "^6.0",
"laravel/tinker": "^1.0",
"laravel/ui": "^1.0"
},
"require-dev": {
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0"
},
"repositories": [{
"type": "vcs",
"url": "https://github.com/albertski/laravel-grid"
}],
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"files": ["tests/utilities/functions.php"]
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
Edit
Just to test it out I created a branch called 3.0_albert and updated the composer.json name field to "name": "albertski/laravel-grid",. (Not a fan of doing this because I eventually want to perform a pull request)
Then ran composer require albertski/laravel-grid:3.0_albert-dev but same issue.
I was able to figure it out. Instead of calling:
composer require albertski/laravel-grid:3.0.x-dev
You call:
composer require leantony/laravel-grid:3.0.x-dev
Basically by adding:
"repositories": [{
"type": "vcs",
"url": "https://github.com/albertski/laravel-grid"
}],
You are telling composer to check your repo first for the package instead of the default one.