lundi 31 juillet 2017

How to implement MVC structure for large scale projects in laravel

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 ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2uOUWFc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire