Laravel can't find a provider from module - php

When I try to start even tinker, I see:
Class 'Modules\BookingSystem\Providers\BookingSystemServiceProvider' not found
But the class is in the specified place. I try to dump autoload with composer but still I get:
> #php artisan package:discover
In ProviderRepository.php line 208:
Class 'Modules\BookingSystem\Providers\BookingSystemServiceProvider'
not found
Script #php artisan package:discover handling the post-autoload-dump event
returned with error code 1
What could be the cause of this?

Given the facts that are present in the question, this seems the most likely solution:
in composer.json chance
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
to
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/",
"Modules\\": "modules/"
}
},
then run composer dump once :)

Related

PHP Fatal error: Uncaught ReflectionException: Class Kernel does not exist [duplicate]

I was trying to go live with a laravel project i developped a year back in school and i ran into some issue.
After uploading the whole project on my hosting service's server, i got these errors on my browser as well as on my SSH shell.
Fatal error: Uncaught exception 'ReflectionException' with message 'Class App\Http\Kernel does not exist' in /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
Stack trace: #0 /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('App\Http\Kernel') #1 /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(659): Illuminate\Container\Container->build('App\Http\Kernel', Array) #2 /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(644): Illuminate\Container\Container->make('App\Http\Kernel', Array) #3 /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(229): Illuminate\Foundation\Application->make('App\Http\Kernel', Array) #4 /home/clients/ffa41f94063 in /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 779
I think it could be related to my namespace configuration, because i haven't all understood yet.
Here is my composer.json file :
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"illuminate/html": "5.*",
"barryvdh/laravel-dompdf": "0.5.*",
"guzzlehttp/guzzle": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "myforms/app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
What I have already done :
Delete /vendor and make a new install with composer install
composer dump-autoload
composer update
btw, I get the error when I insert the composer update
Please inform me if i should post another file that could be useful.
Thanks in advance for your help.
In composer.json change:
"psr-4": {
"App\\": "myforms/app/"
}
to:
"psr-4": {
"App\\": "app/"
}
On the server, in your source directory, run composer update then composer dump-autoload
PSR-4 in Laravel looks for namespaces relative to the root of the project
Check if console/kernel.php is inside of app-folder, if not it might be inside of your laravelApp.
If so, move console/kernel.php to app-folder.
In my case composer.json was missing propper bracket closing "{ }" and line with "psr-4" was in wrong json segment.
Check composer.json for proper align of "psr-4" it should be child of "autoload" section.
Remove vendor
composer install
OK
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"illuminate/html": "5.*",
"barryvdh/laravel-dompdf": "0.5.*",
"guzzlehttp/guzzle": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "myforms/app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
With the help of the other answers here, I realised I'd just missed a change when manually updating from Laravel 5.5 to 5.7
In composer.json, I'd missed this from the autoload block:
"autoload": {
"psr-4": {
"App\\": "app/"
},
...
},
If you're using version control, run composer update on your dev machine to update composer.lock. Then on your production server, you should only need to run composer install

Laravel error on cpanel vendor/composer/autoload_real.php on line 66

Warning:
require(/home/user/public_html/webfolder/vendor/composer/../../app/http/helpers.php):
failed to open stream: No such file or directory in
/home/user/public_html/webfolder/vendor/composer/autoload_real.php on
line 66
I have created a custom helpers.php
My composer.json
"autoload": {
"files": [
"app/http/helpers.php"
],
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
My account on cpanel dont have SSH access, so I cannot run composer dump-autoload or any composer commands. Please help, thanks in advance!!!

Probleme with Symfony 3.3.8 bundle creation

i try to create a bundle by console with symfony 3.3.8 after this version i dont have any problem with that but now i have one,
image1
image2
Any suggestion please!!!!!!
In your composer.json
replace your autoload part with:
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
thinks i also execut the command bellow
composer dump-autoload.
Problem resolve.

Composer auto generated wrong path

I am building a website with Laravel 5.
Laravel is using Composer as dependency management.
Whenever I run composer dump-autoload the autoload classes are generated.
Unfortunately the path in two of these files are wrong.
I am using one Seed class and some migrations within Laravel which is located in database/seeds respectively database/migrations.
The generated paths to all classes (migrations, seeds) below the database folder is wrong.
The path looks like $baseDir . '/atabase/migrations/2017_02_02_153131_create_cards_table.php'
As you can see the "d" from "database" is missing.
As far as I know the autoload classes are defined in the composer.json file.
But here it seems to be correct:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
}
The migration is working, but the seeds are not.
When I do a search&replace and correct the path everything is fine unless I do composer dump-autoload
I am developing on a Windows 10 machine with Laravel 5.4.8 and Composer 1.3.2.
Edit:
Here is the output of composer dump-autoload -vvv
PS C:\Users\phoef\Documents\Projekte\CardViewer> composer dump-autoload -vvv
Reading ./composer.json
Loading config file ./composer.json
Checked CA file C:\Users\phoef\AppData\Local\Temp\composer-cacert- 300c74d6960d46715ffed607c8e36acfa7cbcad49862bb1b67d3c43dea9bfb40.pem: valid
Executing command (C:\Users\phoef\Documents\Projekte\CardViewer): git branch --no-color --no-abbrev -v
Reading C:/Users/phoef/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/phoef/AppData/Roaming/Composer/composer.json
Reading C:\Users\phoef\Documents\Projekte\CardViewer/vendor/composer/installed.json
Reading C:/Users/phoef/AppData/Roaming/Composer/vendor/composer/installed.json
Running 1.3.2 (2017-01-27 18:23:41) with PHP 7.1.1 on Windows NT / 10.0
Generating autoload files
The two files containg the wrong path are: autoload_classmap.php and autoload_static.php.
Edit 2:
Please find below the complete 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"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"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
}
}
The seeds and migrations live in the database/ directory (from project root), not inside app/. Do you'll have database/seeds/CardsTableSeeder.php, for example.
Did you create them using artisan?
php artisan make:migration create_cards_table
php artisan make:seed CardsTableSeeder
It's not required to do it this way but it's handy to be sure you get them in the right directory.
Here's my autoload, you're missing the psr-4 key.
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
}
I have noidea why it's doing atabase, sorry
You are doing something wrong. You need to reset project and start from start.

Composer/Laravel Fatal Error

I added this to my composer.json file
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Claremontdesign\\Cdbase\\": "packages/Claremontdesign/cdbase/src",
"Claremontdesign\\Narbase\\": "packages/Claremontdesign/narbase/src",
"Claremontdesign\\Nhr\\": "packages/Claremontdesign/nhr/src"
},
"files": [
"packages/Claremontdesign/cdbase/src/Helpers/helpers.php",
"packages/Claremontdesign/narbase/src/Helpers/helpers.php",
"packages/Claremontdesign/nhr/src/Helpers/helpers.php"
]
},
then, I ran composer update from the command line, and it gave me this error:
symfony component debug exception fatalerrorexception class "Claremontdesign\Cdbase\ServiceProvider" not found
Has anyone else encountered this?
Also, I added a service provider in add.php
Claremontdesign\Cdbase\ServiceProvider::class
Did you try running just composer dump? composer update runs some scripts before it actually runs - for example php artisan clear-compiled. When artisan runs, it'll probably fail because it tries to register the serviceprovider which isn't autoloaded yet. composer dump only generates the autoload files, which is what you need in this case.
i think you are missing one more slash after every src folder
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Claremontdesign\\Cdbase\\": "packages/Claremontdesign/cdbase/src/",
"Claremontdesign\\Narbase\\": "packages/Claremontdesign/narbase/src/",
"Claremontdesign\\Nhr\\": "packages/Claremontdesign/nhr/src/"
},
"files": [
"packages/Claremontdesign/cdbase/src/Helpers/helpers.php",
"packages/Claremontdesign/narbase/src/Helpers/helpers.php",
"packages/Claremontdesign/nhr/src/Helpers/helpers.php"
]
},

Categories