How do I create sub directories to work in Laravel 5.1?
I am using Laravel 5.1. I usually do to create jobs php artisan make:job SomeJobName
. This would basically create a job SomeJobName
in the directory app/Jobs
. But what if my application is huge. I will end up with a lot of files in this folder. I want to organize it a bit. I want to make sub directories like:
app/Jobs/Users/
Store.php
Update.php
Delete.php
app/Jobs/Posts
Store.php
Update.php
Delete.php
What is the recommended approach for this?
source to share
It's not a problem. Just create them manually and follow PSR naming conventions.
For example, the file app/Jobs/Posts/Store.php
will contain a class like:
namespace App\Jobs\Posts;
use App\Jobs\Job;
class Store extends Job {}
You can copy the rest of the class from the autogenerated version or follow the documentation .
source to share
This should be possible if you change the namespaces later.
Create a subdirectory (like users), copy your work (like Store.php) and change the namespace to namespace App\Jobs\Users;
In the consuming script you need to import it with use App\Jobs\Users\Store;
or use a full qualifier\App\Jobs\Users\Store
source to share