nWidart / laravel-modules

Module Management In Laravel
https://docs.laravelmodules.com
MIT License
5.5k stars 954 forks source link

Laravel 11 The route setting in the module is not effective #1834

Closed chick84 closed 5 months ago

chick84 commented 5 months ago

Problem Description: I created a User module using the module: make command and added a new route in routes/api.php under the User module.

routes/api.php:

<?php

use Illuminate\Support\Facades\Route;
use Modules\User\Http\Controllers\UserController;

/*
 *--------------------------------------------------------------------------
 * 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::any('/user/page', [UserController::class, 'page']);
 php artisan route:list | grep user
  GET|HEAD  api/user .....................................................................................................................................................................................................................................................................                                                                                                                                                                                                                                      

Unable to display this routing record while executing the command, and accessing/API/user/page prompts 404 error Attempted to execute composer dump - o and php artisan module: composer-update without any effect

my composer.json:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The skeleton application for the Laravel framework.",
    "keywords": [
        "laravel",
        "framework"
    ],
    "license": "MIT",
    "require": {
        "php": "^8.2",
        "dcat/laravel-wherehasin": "^0.8.0",
        "intervention/image": "^3.6",
        "james-heinrich/getid3": "^1.9",
        "kalnoy/nestedset": "^6.0",
        "laravel/framework": "^11.0",
        "laravel/horizon": "^5.24",
        "laravel/octane": "^2.3",
        "laravel/sanctum": "^4.0",
        "laravel/telescope": "^5.0",
        "laravel/tinker": "^2.9",
        "maatwebsite/excel": "^3.1",
        "nwidart/laravel-modules": "^11.0",
        "overtrue/easy-sms": "^3.0",
        "spatie/laravel-data": "^4.5",
        "tucker-eric/eloquentfilter": "^3.3"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^3.0",
        "fakerphp/faker": "^1.23",
        "laravel/pint": "^1.13",
        "laravel/sail": "^1.26",
        "mockery/mockery": "^1.6",
        "nunomaduro/collision": "^8.0",
        "phpunit/phpunit": "^11.0.1",
        "spatie/laravel-ignition": "^2.4"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi",
            "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
            "@php artisan migrate --graceful --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        },
        "merge-plugin": {
            "include": [
                "Modules/*/composer.json"
            ]
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
    "config": {
        "allow-plugins": {
            "php-http/discovery": true,
            "wikimedia/composer-merge-plugin": true
        }
    }
}
chick84 commented 5 months ago

Get a solution: delete bootstrap/cache/* Re execute php artisan module:composer-update