Wednesday, August 28, 2013

How to run Composer autoload and CodeIgniter autoload simultaneously

Did you tried to install composer and then you existing CodeIgniter Autoload stop working!!! It happened because __autoload is the old, deprecated way of doing autoloading and you can have only one.

How to run it?
You should register your autoloader using spl_autoload_register.
How you will do it in your code..Here is an example below...

function MY_CI_Autoload($class)
{
 if(strpos($class, 'CI_') !== 0)
 {
  @include_once( APPPATH . 'core/'. $class . EXT );
 }
}

spl_autoload_register('MY_CI_Autoload');

This way your autoloader and composer's will coexist happily.

Saturday, August 17, 2013

My MAMP MySql is not turning on!!!!!!!

I have updated my MAMP version to 2.0 and after that my mysql stop working.
This command worked for me and after running the following in my command line it start working again.. :)
     ps aux | grep mysql 
     lsof -i 
     killall -9 mysqld
if needed
    sudo killall -9 mysqld

Using composer with MAMP’s version of PHP

One tool I have been playing with recently is Composer which is a dependency manager, think Ruby Gems but for PHP. Which is a great little tool and I’m really happy to see the community getting behind it and moving forward. After just trying to install composer I ran into a little problem which I thought was worth sharing.
After running curl -s https://getcomposer.org/installer | php, I get the following error:

Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The detect_unicode setting must be disabled.
Add the following to the end of your `php.ini`:
    detect_unicode = Off


Which looks pretty simple to fix but MAMP should have this setting disabled. So I ranwhich php and I’m told I’m running /usr/bin/php which is the version of PHP that comes preinstalled with OS X. So we just need to swap this over to the PHP that is installed with MAMP, which is located at

 /Applications/MAMP/bin/php/php5.3.6/bin 

To do this I edit my .bash_profile or .profile if you are using a different shell and add the MAMP version of PHP to the PATH variable.

export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:$PATH

It’s important to append the existing $PATH at the end otherwise the version of PHP in /usr/bin/php will be found and loaded first instead. Save the .bash_profile and reload your profile by typing

 source ~/.bash_profile

and run which php, and if you’ve done everything right should say /Applications/MAMP/bin/php/php5.3.6/bin/php.