Sql Server DB connection using php or CakePhp 3.0 in MAMP on windows 7

    1. Download the mssql driver for your php version(in my case it was php 5.6.8) from  here
    2. Extract the .dll files and keep in the  C:\MAMP\bin\php\php5.6.8\ext
    3. Now we have to add the .dll files inside the php configuration file. For this just add the following lines in php.ini which is here   C:\MAMP\conf\php5.6.8
extension=php_pdo_sqlsrv_56_nts.dll
extension=php_sqlsrv_56_nts.dll

extension=php_pdo_sqlsrv_56_ts.dll
extension=php_sqlsrv_56_ts.dll

Connection For php:

<?php 

$serverName = "TOHQLP323\SQLEXPRESS"; //serverName\instanceName
$connectionInfo = array( "Database"=>"TestDb", "UID"=>"", "PWD"=>"");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if($conn){
    echo 'yeah!!!';
}else{

    echo 'Gosh!!!';
}
?>

Connection For CakePHP:

 'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Sqlserver',
            'persistent' => false,
            'host' => 'TOHQLP323\SQLEXPRESS',  //'10.12.22.10'
           //'port' => 'nonstandard_port_number',
            'username' => '',
            'password' => '',
            'database' => 'TestDb',
           // 'encoding' => 'utf8',
            'timezone' => 'UTC',
            'cacheMetadata' => true,
            'log' => false,
            'quoteIdentifiers' => false,          
            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
        ],
 ], 

Now you should be good to go.

Openssl Error while installing Composer with MAMP on windows 7

First, download the Composer-Setup.exe installer for windows environment. When installing using this at some point one error will pop up due to the php openssl extension.

To solve this issue i followed the below steps.

  1. Usually, the php.ini is located under  \MAMP\conf\
  2. Copy the php.ini into a\MAMP\bin\php\php[your PHP version number]\
  3. Restart MAMP
  4. Now install composer
  5. After installing open a command line window and write ‘compser’ you should see it working fine

Thats it.

CakePHP 2 Application Cookbook

Last few days ago i have started reading  CakePHP 2 Application Cookbook   by  Jorge González James Watts.  It includes Over 60 useful recipes for rapid application development with the CakePHP framework.

0083OS_Cake PHP Cookbook

This book was worth reading to get into detail on the following topics:

  • Access control or Authentication for application
  • Smart routing for a cakephp appplication
  • Unit testing
  • Web services and Developing API using cakephp
  • Event management

If you are a CakePHP developer looking to ease the burden of development, then this book is for you. As a headfirst dive into the framework, this collection of recipes will help you get the most out of CakePHP, and get your applications baked in no time. Even if you’re not familiar with the framework, we’ll take you from basic CRUD building to useful solutions that will aid in getting the job done quickly and efficiently.

Laravel setting up in windows 7

In Windows 7 via XAMPP :

  1. First of all we have to download composer from https://getcomposer.org/download/
  2. Now install composer
  3. Open windows shell using cmd
  4. Go to C:/xampp/htdocs
       cd /c/xampp/htdocs
    
  5. Here i will create a laravel project named ” laraveltestapp ” using composer with the following command
    composer create-project laravel/laravel laraveltestapp --prefer-dist
    

     

  6. If the composer cant install laravel then the reason can be that you are behind a proxy server and that restricts composer to download laravel.
  7. In some cases you may need to open up OpenSSL extension for your PHP installation. Open your php.ini file (in C:\xampp\php) uncomment the following line:
    extension=php_openssl.dll

    Just remove the ; in front of it. Once you’ve saved your changes, restart Apache.

  8. From the browser now you can check the project  by typing http://localhost/laraveltestapp/public/
  9. Thats it, now you are ready to play with laravel.