Содержание
- Accessing PHP SDK source code from GitHub
- Install PHP and libraries
- Run the build (and Unit Test)
- Install Ant
- Install QA tools
- Install Autoload
- Install PHP Documentor
- Install Graphviz
- Verify the batch files
- Install vfsStream (Virtual File Stream)
- Install xDebug
- Configure Windows Azure Credentials
- Configure your PHP memory limit for code coverage reports
- Run the build (including unit test)
- Install IDE
Accessing PHP SDK source code from GitHub
Before you start
Download PHP SDK source code via Git
You can perform this task either from Git Bash or from Git GUI:
From the Git GUI, use the following URL:
https://YourGitHubLogin@github.com/WindowsAzure/azure-sdk-for-php.git
From Git Bash, type the following command
git clone -b dev https://YourGitHubLogin@github.com/WindowsAzure/azure-sdk-for-php.git
Install PHP and libraries
Install PHP binary
You need the thread safe version of PHP to be able to run the unit tests. Development is currently done using PHP v5.6+.
Download:
-
MSI: make sure to select the
Fileinfo
andXSL
extensions when prompted by the installer as they are not selected by default. -
.zip: you should get a copy of
go-pear
because sometimes it's not included with the download. You may need to manually install theFileinfo
andXSL
extensions.
During installation, please choose a target path that doesn't contain spaces, as this will prohibit some scripts to run correctly on Windows.
This document assumes that PHP is installed in C:\PHP
Configure PHP
The complete instruction on configuring PHP on your machine is available here at this link.
In practice, PHP configuration comprises making the following changes in php.ini:
-
Search for
cgi.force_redirect
, uncomment it by removing the;
at the begging of the line, and set the value to 0:cgi.force_redirect = 0
-
Search for
cgi.fix_pathinfo
, uncomment it by removing the;
at the beginning of the line:cgi.fix_pathinfo = 1
-
Search for
fastcgi.impersonate
, uncomment it by removing the;
at the beginning of the line, and set the value to 0:fastcgi.impersonate = 0
-
Search for
fastcgi.logging
, uncomment it by removing the;
at the beginning of the line, and set the value to 0:fastcgi.logging = 0
-
Search for
extension=php_mbstring.dll
, uncomment it by removing the;
at the beginning of the line:extension=php_mbstring.dll
-
To enable error reporting set these flags
display_errors = On
display_startup_errors = On
- Set the default time zone:
date.timezone = America/Los_Angeles
Install, upgrade and configure PEAR
From install folder for the PHP runtime, type
go-pear.bat
- select system for the system|local
- type enter for all the questions.
- when go-pear.bat is completed, a new file
C:\PHP\PEAR_ENV.reg
will be created. Double click this file to register it. - upgrade PEAR to the latest version by executing this command:
pear upgrade PEAR
Install required libraries:
Note: If you face any problems, try executing these commands:
pear clear-cache
pear config-set preferred_state beta
You can copy/past this script and it will install all the required libraries
pear config-set preferred_state beta
pear upgrade PEAR
pear clear-cache
pear install http_request2
pear install mail_mime
pear install Mail_mimeDecode
pear install PEAR_PackageFileManager2
pear clear-cache
pear channel-discover pear.pirum-project.org
pear install pirum/Pirum
pear clear-cache
pear config-set auto_discover 1
pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox
pear clear-cache
pear channel-discover pear.netpirates.net
pear channel-discover components.ez.no
pear install theseer/Autoload
pear clear-cache
pear channel-discover pear.phpdoc.org
pear install phpdoc/phpDocumentor-alpha
pear clear-cache
pear channel-discover pear.bovigo.org
pear install bovigo/vfsStream-beta
pear clear-cache
The detailed description for each one is here:
- HTTP_Request2:
pear install http_request2
- Mail_Mime:
pear install mail_mime
- Mail_mimeDecode:
pear install Mail_mimeDecode
Optional libraries are:
-
PEAR_PackageFileManager2:
pear install PEAR_PackageFileManager2
-
pear channel-discover pear.pirum-project.org
pear install pirum/Pirum
Run the build (and Unit Test)
Azure SDK PHP build include PHP documentation, unit testing and more. It is driven by ANT build system.
PHP unit test suite depends on properly installed xDebug and the right Azure account credential. For xDebug installation, please refer to xDebug installation page
Install Ant
The full installation manual for ant is available at Ant installation page
The ant tool can be download from a mirror at Ant Binary Distributions
Installation bottom line:
- Extract the Ant to a place on your disk, e.g.
C:\ant
- Add the bin directory to your path. (add
C:\ant\bin
to yourPATH
environment variable) - Set the
ANT_HOME
environment variable to the directory where you installed Ant.
Install QA tools
PHP QA tools include the unit test, checkstyle, code analysis and many other tools that is useful to ensure high quality PHP coding standard.
pear config-set auto_discover 1
pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox
Install Autoload
Use the following three commands to install Autoload:
pear channel-discover pear.netpirates.net
pear channel-discover components.ez.no
pear install theseer/Autoload
Note: Autoload requires that PHP has the fileinfo module enabled. To enable, make sure that php_fileinfo.dll
reside in ext directory. If php_fileinfo.dll
doesn't exist in ext directory, please download the zip file, and manually copy php_fileinfo.dll
to the ext directory.
Install PHP Documentor
The package page is at phpDocumentor, and can be installed through PEAR using:
pear channel-discover pear.phpdoc.org
pear install phpdoc/phpDocumentor-alpha
Install Graphviz
This tool is used by PHP Documentor to generate class diagram. Install it from Graphviz - Graph Visualization Software
Verify the batch files
Ensure that the following bat files reference the correct path to php.exe within them:
- pdependent.bat
- phpab.bat
- phpcb.bat
- phpcpd.bat
- phpdoc.bat
- phploc.bat
- phpmd.bat
- phpunit.bat
Install vfsStream (Virtual File Stream)
To install vfsStream, use the following commands:
pear channel-discover pear.bovigo.org
pear install bovigo/vfsStream-beta
Install xDebug
The binary of xDebug can be found here, please find one according to your machine's configuration. If you luckily using a Windows Machine, you can find the installation wizard which can help you through the installation process from here http://www.xdebug.org/wizard.php.
Configure Windows Azure Credentials
The unit test requires authenticated access of Windows Azure, a few environment variables need to be configured on the dev box to enable unit test to get authorized properly.
The storage service unit tests use the following environment variables:
AZURE_STORAGE_CONNECTION_STRING
: Connection string to the test storage account.
The Service Management unit tests use the following environment variables:
AZURE_SERVICE_MANAGEMENT_CONNECTION_STRING
: The service management connection string. The format isServiceManagementEndpoint=$endpoint;SubscriptionID=$subscriptionId;CertificatePath=$pathToPemFile
SERVICE_MANAGEMENT_SIMPLE_PACKAGE_CONFIGURATION
: The simple service configuration file for the package located inSERVICE_MANAGEMENT_SIMPLE_PACKAGE_URL
. The service has to include one web role with default values. This file is commonly calledServiceConfiguration.Cloud.cscfg
.SERVICE_MANAGEMENT_SIMPLE_PACKAGE_URL
: URL for a valid azure package uploaded in windows azure blob onSERVICE_MANAGEMENT_SUBSCRIPTION_ID
.SERVICE_MANAGEMENT_COMPLEX_PACKAGE_CONFIGURATION
: The complex service configuration file for the package located inSERVICE_MANAGEMENT_COMPLEX_PACKAGE_URL
. The service has to include one web role and one worker role with 2 instances for each. This file is commonly calledServiceConfiguration.Cloud.cscfg
.SERVICE_MANAGEMENT_COMPLEX_PACKAGE_URL
: URL for a valid complex azure package uploaded in windows azure blob onSERVICE_MANAGEMENT_SUBSCRIPTION_ID
.
The \
sign in the path need to be escaped. For example c:\certificate\testCert.pem
should be c:/certificate/testCert.pem
.
The Media Services unit tests use the following environment variables:
AZURE_MEDIA_SERVICES_ACCOUNT_NAME
: The “Media Service Account Name” you can find it by clicking “Manage Keys” button at Azure control panel.AZURE_MEDIA_SERVICES_ACCESS_KEY
: The “Primary Media Service access key” or “Secondary media service access key” you can find it by clicking “Manage Keys” button at Azure control panel.
The Service Bus unit tests use the following environment variables:
AZURE_SERVICE_BUS_CONNECTION_STRING
: The connection string of the test account for service bus.
To to have these credentials you just need Windows Azure subscription Id which will let you:
- Create storage service (
AZURE_STORAGE_ACCOUNT
andAZURE_STORAGE_KEY
) - Add management certificate to this subscription then use it is *.pem path. (
SERVICE_MANAGEMENT_CERTIFICATE_PATH
)
To add a management certificate read more about Managing Certificates in Windows Azure
Configure your PHP memory limit for code coverage reports
The code coverage reports generation scripts require more memory than what is default in php.ini. The scripts throws this error while generating code coverage reports
Allowed memory size of 134217728 bytes exhausted
To overcome this limitation set memory_limit
config in php.ini to -1
.
Run the build (including unit test)
using cmd.exe, navigate to the PHP SDK project directory, type ant
Install IDE
Install Java Runtime
Download Java Runtime from Java SE Development Kit 7 Downloads and install. For 32 bit operating system, install jdk-7u3-windows-i586.exe
, for 64 bit operating system, install jdk-7u3-windows-x64.exe
.
Install Netbeans
You can use Netbeans as your PHP editor. Download NetBeans full version from NetBeans IDE 7.1.2 Download and install following the instruction. This version of Netbeans has dependency of Java Runtime, as a result, please make sure JDK with version number > 1.6 installed properly.
FAQ
-
When I type
ant
the build fail inphpunit
task without specifying any errors- Make sure that you've installed all required libraries and PHP extensions.
- Make sure that you've added the environment variables and they are reflected in the cmd or NetBeans.
-
When I type ant phpab to generate WindowsAzure.php, I got the errors like this, what shall I do? [exec] Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for '-7.0/DST' instead in C:\PHP\PEAR\TheSeer\Autoload\autoloadbuilder.php on line 285
The answer is to add the following line to php.ini date.timezone = America/Los_Angeles