Composer/Laravel Fatal Error - php

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"
]
},

Related

Laravel forge after each deploy having to use composer update

So I have a helper file: App\helpers.php, added in my JSON as follows:
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"files": [
"app/helpers.php"
]
},
In this helper file I have for example a simple userName() method for displaying the full name of a user:
function userName()
{
return auth()->user() ? auth()->user()->present()->name : '';
}
Everything works fine in my local environment. But everytime I push to my production environment, I get errors:
Call to undefined function userName()
Whenever in Laravel Forge I do a composer update after deploying, the error disappears and my website works flawlessly.
I have never had this issue with any other projects, and I am using the helpers.php file the exact same way.
My question is, why is this happening and of course my second question would be, how to solve this?
if you look at forge deploy script, you'll see the line:
$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader
the --no-dev flag will skip your autoload-dev rules, so you just need to move the helper reference into autoload instead of autoload-dev
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"files": [
"app/Helpers.php"
]
},

laravel doesn't detect my service provider

I'm want create a packagist based in laravel,
I've created a laravel project,
I've created the next directory:
app/
...
packages/
- imfranq/
-- mypackage/
--- src/
---- Providers/
I want use the provider created in my Providers folder
My package composer.json
...
"autoload": {
"psr-4": {
"Imfranq\\MyPackage\\": "src/"
}
}
laravel app.php
'providers' => [
...
Imfranq\MyPackage\Providers\MyPackageServiceProvider::class,
]
I've run make:provider command and I've moved the file to my package folder
My MyPackageServiceProvider.php
public function boot()
{
dd('test');
}
Up to this point nothing works.
I try:
composer dump-autoload command
composer cache:clear command
php artisan clear-compiled command
nothing works
I try in laravel package.json
"autoload": {
"psr-4": {
"App\\": "app/",
"Imfranq\\MyPackage\\": "packages/imfranq/mypackage/src/"
},
"classmap": [
"packages/imfranq/mypackage/src",
"database/seeds",
"database/factories"
]
},
also
"extra": {
"laravel": {
"providers": [
"Imfranq\\MyPackage\\MyPackageServiceProvider"
]
}
},
Not work...

Laravel can't find a provider from module

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 :)

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 exclude-from-classmap not working

so I have the following in my composer.json
"autoload": {
"classmap": [
"database", "app/path1"
],
"psr-4": {
"App\\": "app/"
},
"exclude-from-classmap": [
"/app/path1/Front/"
]
},
and yet when i run composer dump-autoload -o it would still complain about
[Symfony\Component\Finder\Exception\AccessDeniedException]
RecursiveDirectoryIterator::__construct(C:/app\path1\Front\
node_modules\babel-preset-react\node_modules\babel-plugin-transform-react-j
sx\node_modules\babel-helper-builder-react-jsx\node_modules\babel-types\nod
e_modules\babel-traverse\node_modules\babel-code-frame\node_modules\chalk,C
:/app\path1\Front\node_modules\babel-preset-react\node_modu
les\babel-plugin-transform-react-jsx\node_modules\babel-helper-builder-reac
t-jsx\node_modules\babel-types\node_modules\babel-traverse\node_modules\bab
el-code-frame\node_modules\chalk): The system cannot find the path specifie
d. (code: 3)
[UnexpectedValueException]
RecursiveDirectoryIterator::__construct(C:/app\path1\Front\
node_modules\babel-preset-react\node_modules\babel-plugin-transform-react-j
sx\node_modules\babel-helper-builder-react-jsx\node_modules\babel-types\nod
e_modules\babel-traverse\node_modules\babel-code-frame\node_modules\chalk,C
:/app\path1\Front\node_modules\babel-preset-react\node_modu
les\babel-plugin-transform-react-jsx\node_modules\babel-helper-builder-reac
t-jsx\node_modules\babel-types\node_modules\babel-traverse\node_modules\bab
el-code-frame\node_modules\chalk): The system cannot find the path specifie
d. (code: 3)
Which means that it is not really excluding /app/path1/Front/
What am I doing wrong and how can I exclude that directory so that it won't return those exceptions

Categories