makhlugjafarov's avatar

Recurring Issue with Missing api.php and Service Providers in Fresh Laravel Installations

Hello Laracasts Community,

I'm encountering a persistent issue with Laravel installations on my macOS environment and I'm seeking insights or advice from the community.

Issue Description:

In every new Laravel project I create, I'm noticing that the api.php file is missing from the routes directory. Moreover, the app/Providers directory is lacking several of the standard service providers, such as RouteServiceProvider, which are typically present in a fresh Laravel installation. This issue persists even after taking several troubleshooting steps.

Environment:

  • macOS
  • Composer version: 2.7.2
  • PHP version: 8.3.4

Steps Taken So Far:

  1. I've tried creating multiple new projects using the command composer "create-project --prefer-dist laravel/laravel project-name".
  2. I've cleared Composer's cache with composer clear-cache.
  3. I've ensured my Composer and PHP are up-to-date.
  4. Despite these efforts, the api.php file and several service providers are consistently missing in new installations.

Questions:

  • Has anyone else experienced this issue with Laravel installations on macOS?
  • Are there any known compatibility issues or bugs in Laravel latest version that might be causing this?
  • Could this be related to specific settings or configurations in my macOS environment?
  • Any recommendations for further troubleshooting steps would be greatly appreciated.

Thank you in advance for any insights or assistance you can provide. This issue has been quite perplexing, and I'm eager to resolve it and continue with my Laravel development.

0 likes
3 replies
gych's avatar
gych
Best Answer
Level 29

Laravel11 introduced a new application structure. Some files and folders are not added like in previous versions.

If you want the API routes you'll have to use this artisan command:

php artisan install:api

It also only contain the AppServiceProvider, see the release notes about the providers: https://laravel.com/docs/11.x/releases#service-providers

I also advise you to read the all the notes from this release so you're up to date with the new changes. https://laravel.com/docs/11.x/releases

8 likes
mah3uz's avatar

php artisan install:api

and app/bootstrap/app.php

->withRouting(
    web: __DIR__ . '/../routes/web.php',
    commands: __DIR__ . '/../routes/console.php',
    api: __DIR__ . '/../routes/api.php',  // add this line
    health: '/up',
)

Please or to participate in this conversation.