0

I'm building a large scale project with laravel and I'm afraid about the mess structure .

maybe this question is not just relative to laravel but I asked someone for help and he suggested me using jobs for distributing the codes . he suggested calling jobs in every function of controllers and separate jobs and not writing any extra code in controllers! something like this

<?php namespace App\Http\Controllers; use App\Jobs\Page\ShowPageJob; use App\Jobs\Page\StorePageJob; use App\Jobs\Page\UpdatePageJob; class PageController extends Controller { public function store(Request $request) { return $this->dispatch(new StorePageJob($request)); } public function show(Request $request) { return $this->dispatch(new ShowPageJob($request)); } public function update(Request $request) { return $this->dispatch(new UpdatePageJob($request)); } } 

I personally think it would be better if I just try to categories my controllers in folders and separate codes with namespaces .

so

1 - Is using jobs ,like this code an standard way ? if yes what's the benefit of this structure ?

2 - What is the best way for managing structure of large scale projects specially in laravel 5.4 ?

5
  • I'm going to flag this as too broad because I believe it certainly depends on the project itself Commented Jul 31, 2017 at 20:59
  • Maybe you wan't to take a look at this stackoverflow.com/q/23595036/908174 Commented Jul 31, 2017 at 21:06
  • Step 1: don't use laravel. I am actually quite serious, since in large scale project, any benefits, that you might gain, will be insignificant. Especially compared to the penalties, incurred by the technical debt. Commented Jul 31, 2017 at 21:12
  • @tereško then what do you recommend? Commented Jul 31, 2017 at 21:27
  • 2
    I would pick and choose from various composer packages, to get the functionality that I really need (routing lib, di container, templating, mail sender) and do the rest of code custom. The issue wit all these rapid-prototyping frameworks is that, while they are really good at making hello-world level examples, to make them useful in a large project, you actually need extensive experience with those frameworks. Too many people simply use such frameworks as a crutch, because of lack of skills in architecture. Commented Jul 31, 2017 at 21:34

1 Answer 1

0

I worked on small and large projects and would like to say that for small projects you can write all logic in the controller like add, edit, delete, update, show.

While we are working with large projects, We need to maintain our code and need to keep it DRY so I recommend using a repository pattern.

Here is a detailed explanation of the repository pattern and it's worth it or not. repository pattern in laravel

One of package I used for repository pattern, repository pattern package for laravel

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.