Welcome Guest, Not a member yet? Register   Sign In
Controller Filters - Input needed
#7

Just for reference for people who may be unfamiliar with Rails or PHP Middleware:

Rails / My guess of what CI4 would look like with Rails like filters


Code:
namespace App\Controllers;

class Companies extends \Codeigniter\Controller {
   protected $before_action = ['auth', 'cors'];

   public function index($company_id) {
     //This method will only execute after running the 'auth' and 'cors'
     //action set in the $before_action variable
   }
}


The filters/middleware I'm talking about has been in various other frameworks and talked about ad nauseum in blogs. Here are some links

What is middleware?
https://philsturgeon.uk/php/2016/05/31/w...iddleware/
https://www.sitepoint.com/stackphp-explained/
http://stackphp.com/

Different PHP implementations of filters/middleware:
http://www.slimframework.com/docs/concep...eware.html
http://flightphp.com/learn#filtering
https://laravel.com/docs/5.2/middleware
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply


Messages In This Thread
Controller Filters - Input needed - by kilishan - 07-07-2016, 08:39 PM
RE: Controller Filters - Input needed - by arma7x - 07-10-2016, 06:46 AM
RE: Controller Filters - Input needed - by arma7x - 07-07-2016, 09:14 PM
RE: Controller Filters - Input needed - by albertleao - 07-07-2016, 10:32 PM
RE: Controller Filters - Input needed - by arma7x - 07-10-2016, 11:42 PM
RE: Controller Filters - Input needed - by arma7x - 07-12-2016, 01:55 AM
RE: Controller Filters - Input needed - by arma7x - 07-13-2016, 12:23 AM
RE: Controller Filters - Input needed - by arma7x - 07-14-2016, 12:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB