Hello guys, my last article was about "How to install and configure Cygnite PHP Framework using Composer". Today I would like to share a tutorial which will help you day to day activity, also boost up your development. Generating CRUD application is day to day task for almost every developer. Why to spend numerous times on writing CRUD when it is just a 2 minute job to boost up your productivity. Generate you all necessary code for your project as like – INSERT, UPDATE, DELETE, Pagination, Sorting and Field Validation with bootstrap theme etc within just 2 minute.
Sound Interesting? Yes.
Cygnite PHP Framework makes your job easier with fun at working. Learning new framework is fun and gives you learning curve. So let me show you how you can generate all above functionalities with in just 2 minute.
Install Cygnite Framework into your local machine. Set up your database into apps/configs/database.php file
Cygnite CRUD is fully model based. So have your table ready against which you would like to generate CRUD. Or you can use Cygnite Migration to create table schema. Migration is the best practice to build schema but let me not go into Migration in this tutorial. I will explain Migration and seeding another post.
Open your command prompt or terminal. Change the directory to your project root. For example (I am using Windows) if we have installed cygnite into G:\\wamp\www\cygnite\ then you need to enter
We are going to use Cygnite CLI to generate CRUD application so now we need to change directory to
Okay cool! Now we are inside cygnite/console/bin then run below command to generate your CRUD application. Let us assume we are generating crud for table called “user_info”, database name "directory" and we want the controller name as “User”. So our command should be as follows.
php cygnite generate:crud user user_info directory
The above command will generate you CRUD application as Controller, Model, Views, Form Component etc. You can find the files corresponding directories as below.
• cygnite/apps/views/user/index.view.php • cygnite/apps/views/user/create.view.php • cygnite/apps/views/user/update.view.php • cygnite/apps/views/user/view.view.php
You can alter any code to make it fit for your project. That’s all! You are ready to see your application. Go to your browser and type http://localhost/cygnite/user/ you will find your application.
The complete code generation even takes less time if you have configured everything and simply to run crud command.
Hope you found this article useful and make your life easier. Please post me if you have any queries. If you find above tutorial helpful, please don't forget to give a small like or share with friends, also leave your comments below. I really appreciate feedback regarding this CRUD generator from my readers.
Keep visiting for upcoming articles. Cheers! Have a nice day.