Phalcon Developer Tools are very useful for creating core components for your project using simple commands. Using developer tools we can create new projects, controllers, and models in your projects.
This article will help you to install Phalcon developer tools on your system and creating a project with Phalcon Developer Tools in Linux. Before proceeding with this article you must have Phalcon PHP extension enabled in your system. Visit the following URL to install this extension.
>> Install Phalcon PHP Framework on Ubuntu
Install Phalcon Developer Tool
Phalcon Developer Tools can be installed using two methods described below. Select one method only.
Method 1 – Using Git Source
Phalcon developer tools can be install simply downloading source code and create a symbolic link to bin directory. Use following commands to do it.
cd /opt git clone https://github.com/phalcon/phalcon-devtools.git ln -s /opt/phalcon-devtools/phalcon.php /usr/local/bin/phalcon chmod +x /usr/local/bin/phalcon
Method 2 – Using Composer
Using this method you must have composer installed your system. Don’t have composer ? Visit here.
Create a composer.json file under /opt/phalcon/ directory using following content
mkdir /opt/phalcon && cd /opt/phalcon vim composer.json
{ "require": { "phalcon/devtools": "dev-master" } }
Now execute following commands to install tools and create symbolic link to systems bin directory
cd /opt/phalcon composer install ln -s /opt/phalcon/vendor/phalcon/devtools/phalcon.php /usr/local/bin/phalcon chmod +x /usr/local/bin/phalcon
Check Available Phalcon Commands
At this stage, you have successfully configured Phalcon Developer Tools in your system. To check all available commands for creating and managing project use following command.
phalcon commands Phalcon DevTools (3.4.0) Available commands: info (alias of: i) commands (alias of: list, enumerate) controller (alias of: create-controller) module (alias of: create-module) model (alias of: create-model) all-models (alias of: create-all-models) project (alias of: create-project) scaffold (alias of: create-scaffold) migration (alias of: create-migration) webtools (alias of: create-webtools) serve (alias of: server) console (alias of: shell, psysh)
Create A Sample Project
To create a project using Phalcan developer tools, execute the following command. It will create a directory structure for your project.
cd /var/www phalcon create-project myapp
Let’s create a virtual host in your Apache server like below. Nginx users read this to create server block.
<VirtualHost *:80> ServerAdmin [email protected] ServerName phalcon.example.com DocumentRoot /var/www/myapp/public <Directory /var/www/myapp/> Options all AllowOverride all </Directory> </VirtualHost>
After adding above host restart your web server and access website in your browser. You will see default content like below. To change content of default page edit myapp/app/views/index/index.phtml file and add your own content.
3 Comments
chmod +x /usr/local/bin/phalcon
chmod: cannot operate on dangling symlink ‘/usr/local/bin/phalcon’
[email protected]:~$ phalcon commands
After the “`composer install“` command run this command before using “`ls -s command“`:
“`
sudo mv /opt/phalcon/vendor/phalcon/devtools/phalcon /opt/phalcon/vendor/phalcon/devtools/phalcon.php
“`
for rename file phalcon to phalcon.php. Because, I don’t know why, but in the git they downloaded a phalcon file with the name just phalcon, not phalcon.php. So we need to rename this file.
Hi thanku very much and it is useful for me.