Generate Form Class Using Cygnite Form Generator Comand


Hi guys, my last article was about “Getting started with PHP dependency manager Composer”. Today I would like to introduce you with another best tool to generate forms, Cygnite Form generator. Writing html form is old fashion, now days most of the passionate developers does same thing object oriented way. Cygnite Framework CLI gives you breeze and make your development amusing. In some case you may don’t want to generate entire crud operation which Cygnite does cool way.

You are looking for Form generator?

Cygnite CLI is the great tool to cater your development time, generate you form based on your database table with single line of console command. Sounds interesting? Yes.

Let me show you how to get started with forms, before that you need to know folder structure, database configuration etc. with some simple steps.

Cygnite Framework: Folder Structure

Database Configuration

Open database.php file and provide your database configuration as below.


use Cygnite\Database;

    function ($config) {
             'db'  => 'mysql://username:password@hostname/database_name?charset=utf8'

This is one time configuration. You are ready to generate your awesome forms. Remember all your forms will be generating based on your table exists into your database.

Cygnite CLI: Running Form Generator Command

We are ready. Open your console window, Command prompt if you are using Windows and terminal if you are using Ubuntu or linux.

Changing directory. Go to your Cygnite root directory as below. I have installed Cygnite into cygnite-app.

cd /var/www/cygnite-app/console/bin/

Now let us generate form against registration table.

Run below command and press enter.

 php cygnite generate:form table_name database


 php cygnite generate:form registration// Default database connection

Finding and Rendering Form

You can find your form class inside your form component directory. You can see /cygnite-app/apps/components/form/RegistrationForm.php generated. You can generate and access your form as below.

use Apps\Components\From\RegistrationForm;

$form = new RegisterForm(); // create a form object

echo $form->buildForm()->render(); // render your registration form.

Isn’t simple? You may alter the form based on your need. You may have a look at the documentation if you need further detail information about Cygnite Form Builder to alter form elements.


Hope it is useful, once you are ready with database; you are ready to generate n number of forms. Cygnite Framework is under active development and your suggestions and feedback will help us to fulfill all your needs.

If you find above tutorial helpful, please don’t forget to give a small like or share with friends, also leave your comments below.

Have a nice day. Keep visiting for interesting articles.

No comments:

Post a Comment

Follow Us On Facebook Open Source Web Developers by Appsntech facebook group Twitter Open Source Web Developers by Appsntech twitter group Google+ Open Source Web Developers by Appsntech Google group Linkedin Open Source Web Developers by Appsntech, LinkedIn group
Copyright @2011-2015 All rights reserved. Powered By- Sanjoy Dey Productions