Author: Rodrigo Faustino
Updated on: 2023-11-30
Posted on: 2023-11-30
Package: PHP CRUD MVC
Developers can use the capabilities of this package to generate code to implement common functionality that would take more time and be tedious to write manually.
Read this short tutorial article to learn how the PHP CRUD MVC package works and how you can benefit from its code generation capabilities to develop your PHP applications faster using this package or the generator application available on a separate site.
It has been a while since I launched my code generator, PHPCRUD, on the web. You can access it by going to its page at https://phpcrud.ceuvago.com/#/.
Today, I'm excited to announce the 5th version, which can be downloaded via GitHub and is more powerful than ever.
If you want to see the demo video, you can watch this 2-minute video to see you have everything you need to start generating your PHP applications without programming.
In this tutorial you will learn about:
1. Why the PHP CRUD MVC Package Was Developed
2. What is the Structure of Organization of the Class Files Generated by the PHP CRUD MVC Package
3. How to Use the PHP CRUD Web Application to Generate Your CRUD Applications Code
4. How to Download or Install the PHP CRUD MVC Package Using PHP Composer
1. Why the PHP CRUD MVC Package Was Developed
As a technology teacher, I've noticed that some students have difficulties understanding the data flow between the front and back end.
So, I decided to simplify things, expanding the code generator's capability to be straightforward, using pure PHP without all the paraphernalia in a market framework. You can enter the name of the class to be generated, and upon confirmation, several things happen.
2. What is the Structure of Organization of the Class Files Generated by the PHP CRUD MVC Package
Just like every framework, there is an organizational structure of the application files.
When the files are generated, there is a hierarchy of classes and sub-classes inherited from parent classes.
The CRUD classes are sub-classes of the controller classes, which implement a standard approach for performing CRUD operations.
It uses the PHP ReflectionClass to read the metadata of a class. For instance, the insert method receives the class object and reads the properties and their values. Therefore, the properties reflect the columns of the table in the database. Mapping is done within the array for the methods to be as generic as possible, allowing this Crud.php class to be used in any project without issues.
For each table, like the Pessoa table, a model class is created named Pessoa and saved to the file backend/Model/Pessoa.php.
The controller class of the Pessoa class is created and saved to the file backend/Controller/PessoaController.php.
The route definition is also created to define how to handle HTTP GET, POST, PUT, and DELETE methods, calling the ways of the PessoaController.php class to insert, select, update, or delete records. The route definition file is created in Backend/Routes/PessoaRouter.php.
In the tests directory, the corresponding test is created: PessoaTest.php.
Also, three files are created within the js directory at the project root. These three JavaScript files will be responsible for calling the route on the backend. There are three because one is to create the resource, one to fetch all, and a third to bring by ID, updating or deleting as needed.
The HTML presentation files are created, where standard CSS and JavaScript files are imported for the entire operation of the mini-system, thus providing a basic structure to expand your system.
This package has at least PHP 8.2, the Composer tool to install packages, and MySQL as the database server.
3. How to Use the PHP CRUD Web Application to Generate Your CRUD Applications Code
It has been a while since I launched my code generator on the web, PHPCRUD. You can access it by going to the its page at https://phpcrud.ceuvago.com/#/.
Today, I'm excited to announce the 5th version, which can be downloaded via GitHub and is more powerful than ever.
If you want to see the demo video you can watch this 2-minute video to see that you have everything you need start generating your PHP applications without programming.
4. How to Download or Install the PHP CRUD MVC Package Using PHP Composer
The PHP CRUD MVC can be downloaded from download page or be installed using the PHP Composer tool following instructions in the Composer install instructions page.
You need to be a registered user or login to post a comment
Login Immediately with your account on:
Comments:
No comments were submitted yet.