Skip to content

Instantly share code, notes, and snippets.

@jdecode
Last active July 18, 2020 05:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdecode/9d63412a5104a462064dc060b409f387 to your computer and use it in GitHub Desktop.
Save jdecode/9d63412a5104a462064dc060b409f387 to your computer and use it in GitHub Desktop.
Laravel to CakePHP conversion

Instead of Illuminate\Http\Request, use Cake\Http\ServerRequest

Find Request $request and replace with ServerRequest $request

Laravel => routes/web.php CakePHP => config/routes.php

Below examples are for GET routes only, yet

  1. Find and replace Route::get with $builder->connect
  2. Use following regex to convert 'usersController@indexMethod' format of Laravel to ['controller' => 'users', 'action' => 'indexMethod'] format of CakePHP

Find : (', ')([a-zA-Z]+)(Controller)(@)([a-zA-Z]+)(') Replace : ', ['controller' => '$2', 'action' => '$5']

@jdecode
Copy link
Author

jdecode commented Mar 18, 2020

Note : I will continue to add more info in comments (much faster, for now - something like a "writer's debt" - taken, for now, to document stuff faster, not sure when will I repay this).

$request->all() becomes $request->getAttributes()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment