Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Flex's avatar
Level 4

Not working php artisan serve command?

I am working with laravel 5.7 and now I need start server with command php artisan serve in my terminal. but when I type above command and enter my command prompt it is going back to my project root like C:Users\soft\Desktop\laravel\api this was working fine but suddenly occured this problem. how can I fix this problem?

Thanks.

0 likes
14 replies
munazzil's avatar

Check with below commands

    php artisan cache:clear
    php artisan view:clear
Flex's avatar
Level 4

@munazzil my api.php is

<?php

use Illuminate\Http\Request;
Use App\Article;

Route::get('articles', function() {
    // If the Content-Type and Accept headers are set to 'application/json', 
    // this will return a JSON structure. This will be cleaned up later.
    return Article::all();
});
 
Route::get('articles/{id}', function($id) {
    return Article::find($id);
});

Route::post('articles', function(Request $request) {
    return Article::create($request->all);
});

Route::put('articles/{id}', function(Request $request, $id) {
    $article = Article::findOrFail($id);
    $article->update($request->all());

    return $article;
});

Route::delete('articles/{id}', function($id) {
    Article::find($id)->delete();

    return 204;
});

Route::get('articles', 'ArticleController@index');
Route::get('articles/{article}', 'ArticleController@show');
Route::post('articles', 'ArticleController@store');
Route::put('articles/{article}', 'ArticleController@update');
Route::delete('articles/{article}', 'ArticleController@delete');

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
Snapey's avatar

You are running serve from the root of your project? is /api the route folder?

Does php artisan tinker work?

Have you looked in the Laravel log files?

Flex's avatar
Level 4

@snapey my laravel project name is api. and I have developing some api with laravel and above mentioned my api.php file in routes folder. not tinker command working same result.

diegoaurino's avatar

Hello, Flex! How did you install PHP on your system? Did you add PHP to your Windows path variable? Are you running "php artisan serve" on the root folder of your project?

Flex's avatar
Level 4

@diegoaurino yes I have install php correctly. and My other laravel projects are working fine. this problem is only with this project.

diegoaurino's avatar

Try to remove your vendor folder and reinstall it. Also, check your artisan file and compare it with the Laravel's default.

diegoaurino's avatar

Sorry about that, @flex ! I guess we can try something like "php -S localhost:8000 -t public/" on the root folder of your project, so we can see if the PHP's built-in web server can boot.

Snapey's avatar

If tinker is not working also, then probably other commands like php artisan route:list is also broken?

Did you check the log files as suggested?

Normally this type of problem is where you have introduced an issue in a service provider. If you use GIT go back and check what you have changed lately

Please or to participate in this conversation.