在Windows Azure上部署Yii

I wrote a web application based on Yii framework, and now am tending to use Microsoft Azure cloud services.

I'm feeling totally lost, I can't find a single tutorial on this.

How can you configure the Database adapter? Can it be done using SQLSRV driver?

Yii, MVC Framework is based on PHP, so what you really need is to use the Azure PHP SDK to start. My first suggestion will be to download the PHP SDK for Windows Azure from the link below:

http://azurephp.interoperabilitybridges.com/articles/setup-the-windows-azure-sdk-for-php

You will be using Scaffolds which is described below so study properly:

http://azurephp.interoperabilitybridges.com/articles/using-scaffolds

In the above scaffolds there are two samples which you can download and try by yourself (Samples already have connectivity to SQL Azure so you can learn how it is done):

https://github.com/Interop-Bridges/Windows-Azure-Sample-Kit-4-PHP

Finally download the Yii and place into your scaffold folder's root and test it. At last when testing is done you can deploy to Windows Azure.

I hope you may need some help in last step however if you finish using sample application through documentation, you can get Yii in your application easily.

Take a look at some of the tutorials on http://azurephp.interoperabilitybridges.com/tutorials

The tutorials will explain how to get a development environment for PHP for Windows Azure setup.

In particular this one should be useful to you http://azurephp.interoperabilitybridges.com/articles/build-and-deploy-a-windows-azure-php-application

For anyone else finding this question, Re. The database, Azure supports PDO with the SQL Server native driver.

Download the SQL Server PDO extensions from here: http://sqlsrvphp.codeplex.com/

Extract and place the dll(s) into a folder called php/ext under your role/bin folder and also add a line into a php.ini file in the php folder like this: extension=php_pdo_sqlsrv_53_ts.dll

So you end up with:

  • webrole/bin/php/php.ini
  • webrole/bin/php/ext/php_pdo_sqlsrv_53_ts.dll

Then in your php code, you can use the database like any other PDO objects. The connection string will be like this: $conn = new PDO( "sqlsrv:Server= MyServerName ; Database = MyDatabase ", "UserName", "Password123");

This is all I've done and it works fine since PDO is already included by default in the Azure version of PHP.

If you happen to get interested here is a tutorial on how to deploy Yii Framework to Jelastic cloud: Web Development with Yii Framework