Resources

Here are a few exaxmples of how to use Phalcon DevTools (Developer Tools) on Wamp Server (Windows). Installing it is quite straight forward as mention in DevTools instructions. Make sure that you have setup the DevTools and added that directory to your PATH environment variable. For example, we have installed our DevTools in a directory called D:\Wamp\www\phalcon. To create a project, controller etc go to Command prompt (DOS prompt) on Windows or appropriate Linux/Unix directory and execute the appropriate command from below list. Execute the phalcon batch command in your Web server root (D:\Wamp\www) or inside the project directory with appropriate option.

  • To check out the commands (options) available in phalcon command execute it without any options.

    D:\Wamp\www> phalcon

    Phalcon DevTools (3.0.1)

    Available commands:
      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)

  • To check suboptions of any command of phalcon mentioned above specify the option from the above list without any other arguments.

    C:\Wamp\www\test>phalcon controller

    Phalcon DevTools (3.0.1)

    Help:
      Creates a controller

    Usage:
      controller [name] [directory]

    Arguments:
      help  Shows this help text

    Options:
     --name=s             Controller name
     --namespace=s     Controller's namespace [option]
     --directory=s        Base path on which project is located [optional]
     --output=s           Directory where the controller should be created [optional]
     --base-class=s       Base class to be inherited by the controller [optional]
     --force                 Force to rewrite controller [optional]

  • To create a project go to Command prompt (DOS prompt) on Windows and execute the below command. Execute the phalcon batch command in your Web server root (D:\Wamp\www) with option to create a new project, this should create the project directory and also create the directory structure for all project files. This command also creates a file called .phalcon in the project directory which tells phalcon that this is a DevTools created directory.

    D:\Wamp\www> phalcon create-project payroll --enable-webtools

    Phalcon DevTools (1.3.1)
      Success: Controller "index" was successfully created.
      Success: Project 'payroll' was successfully created.

  • To create a multi module project. By default a multi module project is created using numerical values. After the project is created you must rename the directory 1 to payroll in the below example.

    D:\Wamp\www> phalcon create-project --name=payroll --type=modules --directory=payroll --enable-webtools

    Phalcon DevTools (1.3.1)
      Success: Controller "index" was successfully created.
      Success: Project '1' was successfully created.
  • To create all the files corresponding to a database table (model) use the "scaffold" option. It's like creating a scaffolding structure for a model.

    D:\Wamp\www\payroll> phalcon scaffold --table-name=company_m  --get-set --template-engine=volt

    Phalcon DevTools (1.3.1)
      Success: Model "company_m" was successfully created.

    D:\Wamp\www\payroll\app\config/../../app/controllers/CompanyMController.php
    D:\Wamp\www\payroll\app\config/../../app/views//layouts/company_m.volt
    D:\Wamp\www\payroll\app\config/../../app/views/company_m/index.volt
    D:\Wamp\www\payroll\app\config/../../app/views/company_m/search.volt
    D:\Wamp\www\payroll\app\config/../../app/views/company_m/new.volt
    D:\Wamp\www\payroll\app\config/../../app/views/company_m/edit.volt

  • To create a model

    D:\Wamp\www\payroll> phalcon model --name hr_employee_m --get-set

 

  • To create a model with column maps and with a namespace. Column maps are required if you want to use the "assign" function to map all the fields from POST array into a model. Using "assign" function can drastically reduce your code size.

    D:\Wamp\www\payroll> phalcon model --name employee_m --get-set  --namespace=Payroll\Models --mapcolumn

 

  • To create all the files corresponding to a database table (model) with separate namespaces for models and controllers use the "scaffold" option with "ns-models" and "ns-controllers". Note: "--mapcolumn" option doesn't work with "scaffold" so its better to generate the model separately.

    D:\Wamp\www\payroll> phalcon scaffold --table-name=co_country_m  --get-set --template-engine=volt --ns-models=Payroll\Models --ns-controllers=Payroll\Frontend\Controllers

    Phalcon DevTools (3.0.4)

    Success: Model "CoCountryM" was successfully created.

    C:\Wamp\www\payroll\./app/controllers\CoCountryMController.php
    C:\Wamp\www\payroll\./app/views\layouts\co_country_m.volt
    C:\Wamp\www\payroll\./app/views\co_country_m\index.volt
    C:\Wamp\www\payroll\./app/views\co_country_m\search.volt
    C:\Wamp\www\payroll\./app/views\co_country_m\new.volt
    C:\Wamp\www\payroll\./app/views\co_country_m\edit.volt

 

© 2000-2018 Abhikalak Consultants. All Rights Reserved.
Visitors Yesterday: 98 | Total: 34,615