Closed jakecorn closed 6 years ago
Hello,
That means your module was created, the package found your service provider, but composer wasn't able to load the service provider.
Meaning you probably forgot to add the psr-4 part of the documentation.
Thank you for the response.
Im done with psr-4 but the error is still there. This is my code in composer.json
{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": ">=5.6.4", "laravel/framework": "5.4.", "laravel/tinker": "~1.0", "nwidart/laravel-modules": "^1.27" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.", "phpunit/phpunit": "~5.7" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\": "app/", "Modules\": "Modules/" } }, "autoload-dev": { "psr-4": { "Tests\": "tests/" } }, "scripts": { "post-root-package-install": [ "php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "php artisan key:generate" ], "post-install-cmd": [ "Illuminate\Foundation\ComposerScripts::postInstall", "php artisan optimize" ], "post-update-cmd": [ "Illuminate\Foundation\ComposerScripts::postUpdate", "php artisan optimize" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true } }
'composer update' should fix your issue.
or dump autoload (which is run after an update).
I found same issue https://github.com/nWidart/laravel-modules/issues/4, same solution as you have just suggested,this fixed my problem. Thank you
Cool.
I've added this info on the readme and documentation website. 👍
hi, i have this problem in my app laravel5.4 itried to display the output but i get an error of app\Instructor not found still i define it at the top <?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use app\Instructor;
class CreatesController extends Controller
{
public function home(){
$instructors=Instructor::all();
print_r($instructors);
}
}
Arguments
"Class 'app\Instructor' not found"
Oh, i had this same issue, as @nWidart pointed out, I forgot to add "Modules\\": "Modules/"
to my composer.json. As soon as i added it and did composer dump-autoload
, it works.
Thanks for the awesome package @nWidart
Great...I had the same issue but it is all fixed now. Thanks @nWidart
nice guys
Hey Guys, I have a question regarding the usage of namespace (with the laravel-module package). Is that we're tied to using the namespace "Modules" instead of the Developer's name as per below; "Modules\Activity\Providers\ActivityServiceProvider" instead of "DeveloperName\Activity\Providers\ActivityServiceProvider"
return [
/*
|--------------------------------------------------------------------------
| Module Namespace
|--------------------------------------------------------------------------
|
| Default module namespace.
|
*/
'namespace' => 'Modules',
You can config namespace before create new module, It is DeveloperName
return [ /* |-------------------------------------------------------------------------- | Module Namespace |-------------------------------------------------------------------------- | | Default module namespace. | */ 'namespace' => 'Modules',
You can config namespace before create new module, It is DeveloperName
Thanks @SocolaDaiCa. That's what I thought but when I change it I get Class "KerwinEllis\Listing\Providers\ListingServiceProvider" not found.
{
"autoload": {
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/",
"KerwinEllis\\": "Modules/"
}
}
}
you need config autoload
after that, maybe need run composer dumpautoload
, "KerwinEllis\": "Modules/"
Aha, it worked, @SocolaDaiCa thanks a million
Thank you.It worked for me also
Hi, i have problem when testing my laravel api in postman i am getting this error" Error: Class "App\Models\ServiceProvider" not found in file C:\xampp\htdocs\GMS\adminS-laravel\app\Http\Controllers\Api\FormSubmissionController.php on line 22" however i have configured everything that needs to be configured .please help me fix this error
how to fix it Class "Modules\Products\Providers\ProductsServiceProvider" not found in laravel 11
how to fix it Class "Modules\Products\Providers\ProductsServiceProvider" not found in laravel 11
ensure you've updated composer:
from v11.0 autoloading "Modules\": "modules/", is no longer required.
By default, the module classes are not loaded automatically. You can autoload your modules by adding merge-plugin to the extra section:
"extra": {
"laravel": {
"dont-discover": []
},
"merge-plugin": {
"include": [
"Modules/*/composer.json"
]
}
},
Tip: don't forget to run composer dump-autoload afterwards
how to fix it Class "Modules\Products\Providers\ProductsServiceProvider" not found in laravel 11
same issue on laravel 11
"merge-plugin": { "include": [ "Modules/*/composer.json" ] }
its work , Thank you
Run the command: artisan module:publish
Add the "namespace" variable to the items in the "generator" array.
The team forgot about PSR-4 with PHP 8.2.
Done, tnks
On Thu, Mar 28, 2024, 12:22 PM Jonatas Miler Oliveira < @.***> wrote:
Run the command: artisan module:publish Add the "namespace" variable to the items in the "generator" array. image.png (view on web) https://github.com/nWidart/laravel-modules/assets/18699320/77055a84-2507-4e01-8613-87670d25a8fc
The team forgot about PSR-4 with PHP 8.2.
— Reply to this email directly, view it on GitHub https://github.com/nWidart/laravel-modules/issues/283#issuecomment-2024368539, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATCCOZAWISR4QTWZHURY2OTY2OLG5AVCNFSM4DUFBMEKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBSGQZTMOBVGM4Q . You are receiving this because you commented.Message ID: @.***>
In Laravel 11 and Laravel Module 11, ensure that "wikimedia/composer-merge-plugin" is set to true in composer.json, like this:
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true,
"wikimedia/composer-merge-plugin": true
}
},
hi,
I would like to ask about this problem.
I able to create a module named Teacher using this command php artisan module:make Teacher. However, when I create another module or even run php artisan serve it shows me this error.
[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Modules\Teacher\Providers\TeacherServiceProvider' not found
Every command I tried but it shows me the same error I even tried php artisan.
I already added this 'Module' => Nwidart\Modules\Facades\Module::class, to aliases and Nwidart\Modules\LaravelModulesServiceProvider::class, to provider.
please help me , thank you.