make import_namespace detect composer.json
See original GitHub issueHi, thanks for this great plugin. It really help me building Laravel app. I have a sugestion. Is is possible for this plugin to read a configuration for namespace in composer.json
file?
When using Laravel, default composer.json autoload told that all folder in App directory should be namescaped in app
. But, when I use import_namespace this plugin give a full directory url.
Eg. when I run from /User/me/Code/laravel/app/entity/model.php
. It should be App\Entity\Model
based on composer.json autoload configuration.
But, it give me User\me\Code\laravel\app\entity\model
.
Here is sample composer.json files:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"league/commonmark": "0.7.*",
"barryvdh/laravel-ide-helper": "~2.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "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"
}
}
The configuration for namespace is this line:
....
"psr-4": {
"App\\": "app/"
}
....
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Adding namespace to imported third-party package in ...
Adding namespace to imported third-party package in Composer ... I am importing a third-party package into my project using composer. The composer ......
Read more >The composer.json schema
Under the psr-4 key you define a mapping from namespaces to paths, relative to the package root. When autoloading a class like Foo\\Bar\\Baz...
Read more >External dependencies & autoload with Composer
Create the file <module name>/composer.json and paste: ... The classes defined in a namespace can be detected if you ask Composer to scan...
Read more >Autoloading & Namespaces in PHP - Daggerhart Lab
Enter, the use keyword ... The use keyword “imports” a given namespace into the current context, allowing you to make use of its...
Read more >Adding a Custom Class - Laracasts
You can create any custom class inside your ./app directory without changing anything in your composer.json file, as long the namespace is correct....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Added to User Settings the following line and prefix is inserted before the generated part:
Great news everybody !
I finally get it working thanks to code provided by @flashios09 and @dakira.
I will tag this as 2.0 as it’s a huge step forward. You can try the 2.0 release by cloning this repository and checkout the
psr4-support
branch.I will test it for a couple of days/weeks before release.