jeudi 29 octobre 2015

Removing Session and Redirect from Laravel 5 RESTful API

I'm on my way to building a restful API using Laravel 5.1 and it passed my mind disabling completely services that are incompatible with the restful way.

So, I tried to go to config/app.php and I removed:

  • Illuminate\Session\SessionServiceProvider::class, from providers
  • 'Redirect' => Illuminate\Support\Facades\Redirect::class, from aliases
  • 'Session' => Illuminate\Support\Facades\Session::class, from aliases

I also went to app/Http/Kernel.php and removed all the routeMiddleware (later I'll include JWT middleware) and I also removed session related stuffs from middleware variable.

After I did that, I started getting a Class session does not exists when trying to POST to one of my endpoints.

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(CompanyRequest $request) {
    $company = Company::create($request->all());
    return response()->json($company);
}

Anyway, my qusetion is about building a restful api in Laravel 5.1.

  • Do I need to have session related code up and running?
  • Can the session and the redirect be completely removed?
  • Are there any more features that should/could be completely removed for a REST API mode?

And most important of all, how to achieve it?



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

Aucun commentaire:

Enregistrer un commentaire