CakePHP 3 Tutorial 20: Obscure URLs

Submitted by naidim on Thu, 10/27/2016 - 09:33

By default CakePHP uses the unique Id of each record to view each record. For example http://hostname/application/model/view/6. This makes things simple and convenient, except when you want to allow an anonymous user to add and view their record, but no one else. Another user could simply iterate the id field and view all records in the table.

Obscurity is not real security, but can be enough in some instances, and is slightly better than no security at all.

CakePHP 3 Tutorial 19: Display One Thing, Save Another

Submitted by naidim on Tue, 10/25/2016 - 13:37

There may come a case, as in the previous tutorial (CakePHP 3 Tutorial 18: Autocomplete) that you want to display one thing in a form field, yet save a different value. In the previous case, you select a user's name from an autocomplete list, yet the user's id is the value you want to save in the database.

CakePHP 3 Tutorial 15: Neighbors

Submitted by naidim on Tue, 10/18/2016 - 07:58

In CakePHP 2 there was a handy feature called "neighbors" where you could simply request the neighboring records (previous and next) for easy linking. This is not present in CakePHP 3, probably due to the limited use of such a feature, however, with custom finders you can replicate the functionality.

In your model (e.g. src/Models/Table/UsersTable.php) add the following custom finder: