A Blog about web development and Life

Thursday, January 18, 2018

Phalcon project setup using DevTools

What is Phalcon?

Phalcon is an open source, full stack framework for PHP written as a C-extension, optimized for high performance. You don't need to learn or use the C language, since the functionality is exposed as PHP classes ready for you to use. Phalcon also is loosely coupled, allowing you to use its objects as glue components based on the needs of your application.

Phalcon Developer Tools

These tools are a collection of useful scripts to generate skeleton code. Core components of your application can be generated with simple command, allowing you to easily develop application using Phalcon.

Installation of DevTools

Download and Install Phalcon Developer Tools


After installation open DevTools in Command Prompt/Terminal and type,
$ phalcon commands
this will get you list of commands in Phalcon.

Generating a Project Skeleton

You can use Phalcon tools to generate pre-defined project skeletons for your application with Phalcon framework. By default the project skeleton generator will use mod_rewrite for Apache. Type the following command on your web server document root:
$ pwd

/Applications/MAMP/htdocs

$ phalcon create-project hello
simple
├── apps
│   ├── controllers
│   │   ├── IndexController.php
│   │   └── ProductsController.php
│   ├── models
│   │   └── Products.php
│   └── views
│       └── products
│           └── index.phtml
└── public
    └── index.php

More with DevTools

Generating Controllers

$ phalcon create-controller --name test

Preparing Database settings

When a project is generated using developer tools. A configuration file can be found in app/config/config.ini To generate models or scaffold, you will need to change the settings used to connect to your database.

Change the database section in your config.ini file :

[database]
adapter  = Mysql
host     = "127.0.0.1"
username = "root"
password = "secret"
dbname   = "store_db"

[phalcon]
controllersDir = "../app/controllers/"
modelsDir      = "../app/models/"
viewsDir       = "../app/views/"
baseUri        = "/store/"

Generating Models

$ phalcon model ModelName
For more on models visit.

0 comments:

Post a Comment

Search This Blog