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
Related
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...
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!!!
I have created a project in Laravel 5.7 and created the file constants.php in config directory. When I tried to run php artisan config:cache, I am getting the following error.
"ErrorException : Constant XXX_XXX already defined"
I have defined all the constants as define('XXXX_XXXX', 'bla bla'); All these are standard constants needed for my package.
I have done the following:
I have searched the whole project and it is clear that I have never defined the same anywhere else.
If I remove that constant, it shows error at the next define().
If I remove the file from config directory, the artisan command gets executed successfully and I can see the config cache file in bootstrap/cache directory. but my program aborts due to error (as constants are not defined) even after I paste back the file in config directory.
If I remove the config cache file from the bootstrap/cache directory, the code gets executed perfectly normal ( i have not ran the command config:cache).
I very much need this constants and the same time cache the configs to run. I am not able guess the problem.
Note : Contents of config/contants.php all are define('XXX', 'xxx'); Simply echo XYZ; wherever needed. Standard php constants.
try this way
define constant value below
if (!defined('constant')) define('constant', 'value');
I am not sure whether it is correct but the way it worked is as follows:
I moved the constants.php from App/config/ to App/ (along with other models)
I modified the composer.json in the "autoload" with
"files": [
"app/constants.php"
]
I ran composer dump-autoload
Then I ran the php artisan config:cache
It had build the new config file in bootstrap and the code is executing normal.
i have a great solution for this. please follow this step :
1 -> add new file constantHelper.php inside directory app/Helpers
2 -> edit file composer.json and set auto load files
{
"autoload": {
"files": [
"app/Helpers/constantHelper.php"
]
},
"autoload-dev": {
"files": [
"app/Helpers/constantHelper.php"
]
}
}
this is my complete code inside composer.json
{
"name": "nurzazin/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": [
"laravel",
"lumen"
],
"license": "MIT",
"type": "project",
"require": {
"php": "7.3.*",
"ext-json": "*",
"ext-openssl": "*"
},
"require-dev": {
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0",
"wn/lumen-generators": "^1.3"
},
"autoload": {
"files": [
"app/Helpers/constantHelper.php"
],
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"files": [
"app/Helpers/constantHelper.php"
],
"classmap": [
"tests/"
]
},
"minimum-stability": "dev",
"prefer-stable": true
}
3 -> run command composer install or composer dump-autoload
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.
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"
]
},