Reputation: 2183
I am working in project where I need to upgrade the Lumer version from 5.1.* to 7.*.
But I have been stuck at the versions 5.4.*
and 5.5.*
. Where in 5.4.*
when I ran the built-in php server php -S localhost:8000 -t ./public
and visited the URL http:\\localhost:8000
, I got the below error:
Call to undefined method ...\Application->welcome()
But I upgraded to next version hoping that would solve this issue, as I hadn't changed any of files outside vendor
folder.
But after I upgraded to Lumen 5.5.* version, and now when I run any php artisan
command, I am getting below error:
In routes.php line 17:
Call to undefined method Laravel\Lumen\Application::post()
Can anyone share idea on what's wrong and how to fix both the aforementioned errors ?
This is composer.json file of project, just in case it helps:
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/lumen-framework": "5.5.*",
"vlucas/phpdotenv": "~2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/"
]
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"config": {
"preferred-install": "dist"
}
}
app/Http/routes.php:
<?php
date_default_timezone_set('America/Chicago');
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
//$app->group(['middleware' => 'FilterInput'], function($app) {
$app->post('app_details', ['as' => 'app_details', 'uses' => 'App\Http\Controllers\Details@set_app_details']);
$app->post('phone_details', ['as' => 'phone_details', 'uses' => 'App\Http\Controllers\Details@set_phone_details']);
$app->post('app_search', ['as' => 'from_search', 'uses' => 'App\Http\Controllers\Details@set_search_details']);
$app->post('app_lead', ['as' => 'from_search', 'uses' => 'App\Http\Controllers\Details@set_lead_details']);
$app->post('survey', ['as' => 'survey', 'uses' => 'App\Http\Controllers\Survey@set_data']);
//capture all routes regardless
$app->get('{path:.*}', function() use ($app) {
return $app->welcome();
});
//});
bootstrap/app.php
excerpt:
...
...
require __DIR__.'/../app/Http/routes.php';
return $app;
Upvotes: 1
Views: 2051
Reputation: 9604
As you may see here $app
is no longer used - instead you use $router
.
$router->get('/', function () use ($router) {
return $router->app->version();
});
The previous version was like this
After updating the routes by replacing $app
with $router
; the bootstrap/app.php becomes like this
$app->router->group(['namespace' => 'App\Http\Controllers'], function ($router) {
require __DIR__ . '/../app/Http/routes.php';
});
Upvotes: 1