From 5334110e8bea7db0dc5a3e1092564000ead3401e Mon Sep 17 00:00:00 2001 From: Dengke Tang <815825145@qq.com> Date: Wed, 1 Mar 2023 16:18:25 -0800 Subject: [PATCH] Intructions update (#89) - add .gitattributes to cut down the composer package size. - Update README for instruction to install from package managers and build from source for windows. --- .gitattributes | 21 ++++++++++++++ README.md | 77 ++++++++++++++++++++++++++++++++------------------ composer.json | 5 +++- 3 files changed, 74 insertions(+), 29 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8479dcd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +.github/ export-ignore +crt/ export-ignore +ext/ export-ignore +tests/ export-ignore +dev-scripts/ export-ignore +.clang-format export-ignore +.clang-format-ignore export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.gitmodules export-ignore +CONTRIBUTING.md export-ignore +Makefile.frag export-ignore +Makefile.frag.w32 export-ignore +builder.json export-ignore +config.m4 export-ignore +config.w32 export-ignore +format-check.sh export-ignore +gen_api.php export-ignore +gen_stub.php export-ignore +php-win.ini export-ignore +php.ini export-ignore diff --git a/README.md b/README.md index e793483..f8f3691 100644 --- a/README.md +++ b/README.md @@ -3,52 +3,73 @@ ## Requirements * PHP 5.5+ on UNIX platforms, 7.2+ on Windows * CMake 3.x -* GCC 4.4+, clang 3.8+ on UNIX, Visual Studio 2017 build tools on Windows +* GCC 4.4+, clang 3.8+ on UNIX, Visual Studio build tools on Windows * Tests require [Composer](https://getcomposer.org) -## Building on UNIX +## Installing with Composer and PECL + +The package has two different package published to [composer](https://packagist.org/packages/aws/aws-crt-php) and [PECL](https://pecl.php.net/package/awscrt). + +On UNIX, you can get the package from package manager or build from source: + +``` +pecl install awscrt +composer require aws/aws-crt-php +``` + +On Windows, you need to build from source as instruction written below for the native extension `php_awscrt.dll`. And, follow https://www.php.net/manual/en/install.pecl.windows.php#install.pecl.windows.loading to load extension. After that: + +``` +composer require aws/aws-crt-php +``` + +## Building from Github source + ```sh $ git clone --recursive https://github.com/awslabs/aws-crt-php.git $ cd aws-crt-php $ phpize $ ./configure -$ make && make test +$ make +$ ./dev-scripts/run_tests.sh ``` ## Building on Windows -* First, ensure that you are able to build PHP on windows via the PHP SDK (this example assumes installation of the SDK to C:\php-sdk and that you've checked out the PHP source to php-src within the build directory). The following resources are helpful to get PHP building on windows: - * https://github.com/microsoft/php-sdk-binary-tools - * https://medium.com/@erinus/how-to-build-php-on-windows-a7ad0a87862a - * https://medium.com/@erinus/how-to-build-php-extension-on-windows-d1667290f809 -```bat -""" From VS2017 Command Prompt -> C:\php-sdk\phpsdk-vc15-x64.bat +### Requirements for Windows + +* Ensure you have the [windows PHP SDK](https://github.com/microsoft/php-sdk-binary-tools) (this example assumes installation of the SDK to C:\php-sdk and that you've checked out the PHP source to php-src within the build directory) and it works well on your machine. + +* Ensure you have "Development package (SDK to develop PHP extensions)" and PHP available from your system path. You can download them from https://windows.php.net/download/. You can check if they are available by running `phpize -v` and `php -v` + +### Instructions + +From Command Prompt (not powershell). The instruction is based on Visual Studio 2019 on 64bit Windows. + +``` bat +> git clone --recursive https://github.com/awslabs/aws-crt-php.git +> git clone https://github.com/microsoft/php-sdk-binary-tools.git C:\php-sdk +> C:\php-sdk\phpsdk-vs16-x64.bat C:\php-sdk\ -$ phpsdk_buildtree php- +$ cd -C:\php-sdk\php-\vc15\x64\ -$ git clone https://github.com/php/php-src.git && cd php-src +\ +$ phpize -""" This only has to be done once, the first time you set this all up -C:\php-sdk\php-\vc15\x64\php-src -$ phpsdk_deps --update --branch +# --with-prefix only required when your php runtime in system path is different than the runtime you wish to use. +\ +$ configure --enable-awscrt=shared --with-prefix= -C:\php-sdk\php-\vc15\x64\php-src -$ git clone --recursive https://github.com/awslabs/aws-crt-php.git ..\pecl\awscrt - -C:\php-sdk\php-\vc15\x64\php-src -$ buildconf - -C:\php-sdk\php-\vc15\x64\php-src -$ configure --enable-cli --with-openssl --enable-awscrt=shared - -C:\php-sdk\php-\vc15\x64\php-src +\ $ nmake -C:\php-sdk\php-\vc15\x64\php-src -$ nmake test-awscrt +\ +$ nmake generate-php-ini + +# check .\php-win.ini, it now has the full path to php_awscrt.dll that you can manually load to your php runtime, or you can run the following command to run tests and load the required native extension for awscrt. +\ +$ .\dev-scripts\run_tests.bat ``` Note: for VS2017, Cmake will default to build for Win32, refer to [here](https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2015%202017.html). If you are building for x64 php, you can set environment variable as follow to let cmake pick x64 compiler. diff --git a/composer.json b/composer.json index 95127dd..37f8193 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "aws/aws-crt-php", - "homepage": "http://aws.amazon.com/sdkforphp", + "homepage": "https://github.com/awslabs/aws-crt-php", "description": "AWS Common Runtime for PHP", "keywords": ["aws","amazon","sdk","crt"], "type": "library", @@ -25,6 +25,9 @@ "src/" ] }, + "suggest": { + "ext-awscrt": "Make sure you install awscrt native extension to use any of the functionality." + }, "scripts": { "test": "./dev-scripts/run_tests", "test-extension": "@test",