Generate Crud Routes

Tina4 has a unique way to generate crud routes for you for use in your API.

Let me show you how I create an API route for a Users ORM class.

Create an ORM Class for your Table first if you have not done so yet.

1. To start out create a file in your routes/api directory.

  • In this example I want to make a route that responds to /api/user.
  • I want to get data from the Users ORM object I created.


(new User())->generateCRUD("/api/user/");
//   ^                       ^  
// Your ORM object          Desired API Endpoint

2. Now for the fun part 8-). Execute your code by visiting your site. I.e. http://localhost:7171

Make sure you hit a route that does not get served from cache or this won't work.

3. Return to the file and you'll find Get, Post, Delete … API routes already written for your ORM Object.

4. Customize and enjoy

Powered by ComboStrap