Laravel 5 - Change Models,Views,Controllers path - php

i have edited psr-4 on composer.json
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"Marka\\Urun\\": "vendor/Marka/Urun/src/",
"App\\": "app/"
},
"files": [
"vendor/Marka/Urun/src/helpers.php"
]
},
I want to change file(routes.php, helpers.php and Models,Views,Controllers) pathes to :
Vendor/Marka/Urun/
How can I do it ?

You're trying to get some modular structure if I get it right.
If so, instead of trying to set a different namespacing from composer for each of your modules under vendor directory; i think you may try to use something like http://sky.pingpong-labs.com/docs/2.0/modules
Otherwise as you may know, by using PSR-4 and directory structure, if you coded your files properly all necessary files would be loaded automatically as you named (namespaced) them.
By the way, just in case you didn't know you may also need a ServiceProvider to boot everything up for Laravel on your package.
I also suggest you to read https://laravel.com/docs/5.2/packages if you need any help about development structure/functionality.

Related

NetBeans does not see a returning types of custom helper functions (Laravel, PHP)

I added my custom helpers file to Laravel project using composer.json like this
"autoload": {
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Helpers/helpers.php"
]
},
And I checked, the same way Laravel's helper file is added to the project. This one: \vendor\laravel\framework\src\Illuminate\Foundation\helpers.php
It is all working fine.
But
In my Netbeans type-hinting helper does not see returning type of the functions of my file. However it sees returning type of Laravel's helpers.
Why? How can I fix this?
I tried Netbeans 8 and 10 - same problems.

Linking a new Helper File in CakePhp 3 via Composer

I am using Cake PHP 3, and under the src folder, I created a new folder called Helper and created a new file inside it. And now I went to composer.json and added the required file key inside the autoload. You can see it below:
"autoload": {
"psr-4": {
"App\\": "src"
},
"files": [
"./src/Helper/general_helper.php"
]
}
But after, doing composer dump-autoload, getting require(/opt/lampp/htdocs/project_name/vendor/composer/../../src/Helper/general_helper.php):
Its not under the vendor folder, I think that's why its giving the error. Any idea, how to solve this issue, cause I want to maintain a separate folder. Thanks.

Generate Class-Map including PHPdoc from all classes within a directory

I have a php application build on top of the Laravel framework. All my application specific modules are placed in their own Modules directory Modules\[Modulname].
These modules are autoloaded via PSR-4 in my composer.json:
"autoload": {
"classmap": [
...
],
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/"
}
},
Is there a way to get an array or something containing all classes, traits and interfaces with all containing methods, attributes and PHPdoc-blocks from the Modules-directory ordered according to the namespace?
I want to build a documentation similar to the Laravel Api documentation.

Autoload folder without changing composer.json file - Laravel 5.4

I've created a package that creates a folder in the root of the project.
Creating it in the app folder is for me not clean enough. Cause I don't want it to look like it's merged with the laravel framework.
This package is for our company and will be used a lot.
So instead of changing the composer.json file everytime to add the folder to the autoloader I'm trying to just autoload it from the package.
Is something like that possible and how?
Are you saying that you do not want to add it in your composer.json file here?
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Company\\": "company/"
}
},
That is what I would do.
What if you just use the folder structure as the autoloader namespace? That should work. For example:
<?php
use Company\Foo;
new Bar();
Where you would have a folder called company/Foo with all the classes inside declaring their namespace like so:
<?php
namespace Company\Foo;
class Bar {
//
}

Laravel 5 assets and lang folder in separate modules

I am trying to split my application out into seperate "modules".
I am not sure whether to leave the assets folder where it is and put everything in there for every module or how I would go about giving each module their own assets folder.
What is the best approach and what would I have to do in order to access the assets folders from each module?
Here is my directory structure so far:
Also am I right to put a Requests folder in each module?
Here is there relevant composer.json section:
"autoload": {
"classmap": [
"database",
"app/Modules"
],
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/"
}
},
Take a look at the Packages section in the official Laravel documentation. It has sections on keeping things like translation files and other assets in your package, and publishing them when including your package in your applications.

Categories