Matt
Matt

Reputation: 1131

Run a Laravel 4 request as light as possible

Within a Laravel application I have a messenger polling system. With this I'm guessing that every time a user makes a request all dependencies get loaded with every request. Not really a feature I'm very fond of seeing the load it potentially creates.

Is there a way to circumvent most of Laravel requirements to run.

I really only want to insert a message in the database and select a return response and return it as JSON. So I'm not in need of any views, controllers or modules and want to keep those as clean as possible. I actually don't even want to use the PDO and definitely not the query builder.

I'm guessing it saves a lot of server power just to go from the

Route::post(... function({}));

Can anybody confirm?

Upvotes: 0

Views: 70

Answers (1)

Laurence
Laurence

Reputation: 60038

Alot of Laravel components are "lazy loaded" - so they only actually load when they are needed.

Is there a way to circumvent most of Laravel requirements to run. I really only want to insert a message in the database and select a return response and return it as JSON. So I'm not in need of any views, controllers or modules and want to keep those as clean as possible. I actually don't even want to use the PDO and definitely not the query builder.

To me it seems you want to not use most of the Laravel framework. So if I was you - dont use the Laravel framework. Just use the Request component by itself, or even use the underlying Symphony component.

However, as a side point, it seems like you are trying to optimise something where you dont even know you need to optimise it in the first place. Focus on writing good quality, testable, maitainable code.

The other option is a 'light' framework like Silex

Upvotes: 4

Related Questions