Skip to main content

Installing Phalcon Developer Tools 1.3.1 in Ubuntu 13.10 / 14.04

Installing developer tools requires slightly more effort.
Download phalcon-developer-tools package here: 
         https://github.com/phalcon/phalcon-devtools 
Extract it to some convenient path.
Via git : 
        git clone git://github.com/phalcon/phalcon-devtools.git 
Install and create a phalcon symlink:
       cd phalcon-devtools
       sudo ./phalcon.sh
Create a symbolink link to the phalcon.php script, replace this with the right path:

      alias phalcon="/home/sherwinrobles/phalcon-devtools/phalcon.php"
Remember to restart the console to reload the environment variables. Let’s try it out by listing available commands. 

       phalcon commands
Gives me this error:
     PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/phalcon.so' - /usr/lib/php5/20121212/phalcon.so: undefined symbol: php_pdo_get_dbh_ce in Unknown on line 0
ERROR: Phalcon extension isn't installed, follow these instructions to install it: http://docs.phalconphp.com/en/latest/reference/install.html

Solution:

Instead of php.ini it looks for phalcon extension in /etc/php5/cli/conf.d/ & /etc/php5/apache2/conf.d/ folder.

You need to load PDO first before Phalcon.
The ini file that loads phalcon should be prefixed to a number higher than the one PDO is. So in my system I have:
          /etc/php5/cli/conf.d/50-phalcon.ini 
         /etc/php5/apache2/conf.d/50-phalcon.ini 

Create each and paste this: extension=phalcon.so 
Find loaded php.ini with these commands. 

           sudo php -i | grep 'Configuration File'                

           Configuration File (php.ini) Path => /etc/php5/cli               
           Loaded Configuration File => /etc/php5/cli/php.ini


Remove the line "extension = phalcon.so" if you previously add this from the main php.ini file
Congratulations you now have Phalcon tools installed!


Post a Comment

Popular posts from this blog

CakeAdminLTE is based on AdminLTE Theme for CakePHP 2.4+

CakeAdminLTE v.1.0 CakeAdminLTE is based on Twitter Bootstrap 3.0+ and AdminLTE Theme for CakePHP 2.4+


AdminLTE Dashboard and Control Panel Template  Responsive admin template Free & open source Built with Bootstrap 3 Easy to customize Quick StartDownload the .zip fileExtract the files into your CakePHP folderTo enable your theme add the following to your "app/Controller/AppController.php" class:public$theme="CakeAdminLTE"; IMPORTANT: If you would like to bake your app, please make sure you have enabled the theme before baking. DOWNLOAD: CakeAdminLTE

CakePHP: COUNT data and GROUP BY date

Goal: Count Tip Offs created per day for a month to use for graph
Problem: created field name is in datetime format: Y-m-d H:i:s
Solution: format SQL Query date: DATE_FORMAT(TipOff.created, '%Y-%m-%d')





Inside the function of controller
<?php$tipOffsMonthly=$this->TipOff->find('all', array('conditions'=>array('AND'=>array('TipOff.electric_cooperatives_id'=>AuthComponent::User('electric_cooperatives_id'), 'TipOff.created BETWEEN ? AND ?'=>array($first_day, $last_day))), 'fields'=>array("COUNT('created') as per_day", 'created'), 'group'=>array("DATE_FORMAT(TipOff.created, '%Y-%m-%d')") ));?>

CakePHP: Calling function from other controller

Import Controller of the function you want to use.

Once you imported  the controller you can call any function of this controller.

<?php//Import controller  App::import('Controller','SmsOutgoings');class ReportsController extends AppController {publicfunctionadd(){$message="Notification: New report submitted!";//Instantiation$SmsOutgoings=new SmsOutgoingsController;//Call a method from SmsOutgoingsControllerwith parameter$SmsOutgoings->notify_user($user_id,$message);}}?> Other way is by using the requestAction() function
<?phpclass ReportsController extends AppController {publicfunctionadd(){$message="Notification: New report submitted!";//Call a method from SmsOutgoingsController with parameter$this->requestAction('/sms_outgoings/notify_user',array($user_id,$message))