You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Composer安装Laravel后routes目录缺失问题求助

Troubleshooting Missing routes Directory in Your Laravel Installation

Hey there! Since you're coming from CodeIgniter, Laravel's directory structure might feel a bit different at first—let's get that missing routes directory sorted out.

First, let's check the most common reason for this: Laravel version differences. Starting with Laravel 11, the framework simplified its directory structure, and the routes folder is now located inside the app directory (app/routes) instead of the project root. If you installed the latest version but were looking at documentation for Laravel 10 or older, that's exactly why you didn't see it in the root!

To confirm your Laravel version, navigate into your project folder in CMD and run:

php artisan --version

If you're running Laravel 11:

Just head over to app/routes—you'll find all your route files there (like web.php, api.php) right where they should be. This is the new default structure, so the docs you were looking at might be outdated.

If you're running Laravel 10 or earlier but still missing the root routes directory:

This is likely due to a partial or interrupted installation. Try these steps:

  • Delete the existing project folder: In CMD, run rmdir /s laravel (Windows) or rm -rf laravel (Mac/Linux) to remove the incomplete installation.
  • Clear Composer's cache: Run composer clear-cache to make sure you're pulling fresh files.
  • Re-run the installation command:
    composer create-project --prefer-dist laravel/laravel laravel
    
    Make sure your internet connection stays stable during the install—interruptions can cause missing files.

If re-installing still doesn't work:

You can manually create the routes directory in your project root and add the default route files. For example:

  • Create routes/web.php with this basic content:
    <?php
    
    use Illuminate\Support\Facades\Route;
    
    Route::get('/', function () {
        return view('welcome');
    });
    
  • You can grab the other default route files (api.php, console.php, channels.php) from the official Laravel repository's matching version branch to keep things consistent.

Since you know CodeIgniter, think of this like how CodeIgniter keeps routes in application/config/routes.php—Laravel just organizes them in a dedicated folder, with separate files for web, API, and console routes to keep things clean.

内容的提问来源于stack exchange,提问作者Supun Abesekara

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:03:57