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.

Step 1

Create a file in your routes/api director

  • 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.
<?php

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

Step 2

Execute your code by visiting your site. I.e. http://localhost:7171- 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.

Step 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