Slim 4 RESTful API with data models automation

I would love to have your feedback :pray: on a dynamic boilerplate I just built with Slim 4, MySQL & Docker.

This boilerplate provides a RESTful API with session management stored in Redis

GitHub - tractr/boilerplate-slim-php: Dynamic boilerplate providing an API built with Slim PHP, MySQL and Docker (build for Hapify.io)

As a special feature, this boilerplate embed a data-models driven code designed for Hapify.io automation engine :robot:

For each data models, the automation engine will instantly output these routes : create, read, update, delete, search and count, including user permissions.

The automation engine has a functional approach of the data-modeling. For instance:

  • if you define the name property in a user model as searchable, then a search and count routes will automatically be created, allowing you to filter users by name.

  • if you define that an object like a place is updatable only by its owner, then the generated route PATCH /place will automatically check if the caller is the place owner or admin.

To learn more about this modeling approach you can browse the documentation :page_facing_up:

Back to our Slim boilerplate, if you would like to see a quick example of generated project , you can download this ZIP file.

If you want to try directly Hapify, you can either refer to the get started or follow these steps:

  1. Install the hapify-cli:

npm i -g hapify-cli

  1. Connect the hapify-cli to our demo user

hpf key Y5xk5O4QGMZqRVnI341gxyaVbfQvEwd2ZtTNTHWgAb7pLglD

  1. Create an empty folder for the demo

mkdir slim-demo && cd slim-demo

  1. Clone the boilerplate and connect it to the example project

hpf new --boilerplate slim_php_tractr --project 5e56a84257b31a0010383107

  1. If you would like to edit data-models and/or code templates, you can run:

hpf serve

  1. Generate the code

hpf generate

Now you can browse the boilerplate’s code especially the generated part.

If you want to edit the project again, you may run hpf generate to update the output code.

If you want to run the API (with Docker) please follow the step 3 in the README.md file

Now that you have a running API, you may want to connect a front-end to it. Let’s use an Angular Dashboard.

In a new folder, run these commands:

hpf new --boilerplate ngx_dashboard_tractr --project 5e56a84257b31a0010383107
hpf generate
npm install
npm start

Here is more information about this boilerplate.

If you did go through this, thank you for your time.

We are really looking for your feedbacks!!

Cheers!

Edouard

1 Like