-
Notifications
You must be signed in to change notification settings - Fork 274
Update Composer install section in README.md
#788
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ Microsoft Azure tables, blobs, queues, service bus (queues and topics), service | |
* deployment: create, get, delete, swap, change configuration, update status, upgrade, rollback | ||
* role instance: reboot, reimage | ||
* REST API Version: 2011-10-01 | ||
* Media Services | ||
* Media Services | ||
* Connection | ||
* Ingest asset, upload files | ||
* Encoding / process asset, create job, job templates | ||
|
@@ -47,7 +47,7 @@ Microsoft Azure tables, blobs, queues, service bus (queues and topics), service | |
* Scale encoding reserved unit type | ||
* REST API Version: 2.11 | ||
|
||
|
||
# Getting Started | ||
## Download Source Code | ||
|
||
|
@@ -57,26 +57,33 @@ To get the source code from GitHub, type | |
cd ./azure-sdk-for-php | ||
|
||
> **Note** | ||
> | ||
> | ||
> The PHP Client Libraries for Microsoft Azure have a dependency on the [HTTP_Request2](http://pear.php.net/package/HTTP_Request2), [Mail_mime](http://pear.php.net/package/Mail_mime), and [Mail_mimeDecode](http://pear.php.net/package/Mail_mimeDecode) PEAR packages. The recommended way to resolve these dependencies is to install them using the [Composer package manager](http://getcomposer.org). | ||
|
||
|
||
##Install via Composer | ||
1. Make sure you have installed **[Compoeser](https://getcomposer.org/doc/00-intro.md#introduction)** in your system. | ||
It can be installed locally or globally depending on your own needs. | ||
|
||
2. You can edit your `composer.json` file manually or directly add the requirement via CLI: | ||
|
||
* Create a file named **composer.json** in the root of your project and add the following code to it: | ||
###Manually edit | ||
Create or edit your **composer.json** in the root of your project and add the following code to it: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this section, I would just use the original text, so new users will not be distracted by composer operations. |
||
```json | ||
{ | ||
"require": { | ||
"microsoft/windowsazure": "^0.4" | ||
} | ||
{ | ||
"require": { | ||
"microsoft/windowsazure": "^0.4" | ||
} | ||
} | ||
``` | ||
|
||
* Download **[composer.phar](http://getcomposer.org/composer.phar)** in your project root. | ||
|
||
* Open a command prompt and execute this in your project root | ||
|
||
php composer.phar install | ||
php composer install | ||
|
||
###Add requirement and install with one command | ||
Execute the following command in order to get this package: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make sure you have included all necessary config steps for composer to work here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only command required @yaqiyang, you think I missed something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "It can be installed** locally or globally **depending on your own needs. ". But you told me you have to install it globally for your command to work. I know it does not work on my machine since I have not got a chance to install composer yet. I only have composer.phar downloaded. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I said @yaqiyang, I have installed globally, and I renamed |
||
php composer create-project microsoft/windowsazure /path/to/install/dir ^0.4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to have .phar here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you try your command? php composer.phar create-project microsoft/windowsazure ./test2 ^0.4 will try to install v0.4.0, not v0.4.2. php composer.phar create-project microsoft/windowsazure ./test3 ^0.4.2 does not work either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are so many hoops to jump, this will not work for beginners which is the Readme file for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yaqiyang, I'll try to address your comments one by one:
Obviously, it depends on which mechanism the user chooses based on the install documentation: https://getcomposer.org/doc/00-intro.md
|
||
|
||
> **Note** | ||
> | ||
|
@@ -86,12 +93,12 @@ To get the source code from GitHub, type | |
|
||
## Getting Started | ||
|
||
There are four basic steps that have to be performed before you can make a call to any Microsoft Azure API when using the libraries. | ||
There are four basic steps that have to be performed before you can make a call to any Microsoft Azure API when using the libraries. | ||
|
||
* First, include the autoloader script: | ||
|
||
require_once "vendor/autoload.php"; | ||
require_once "vendor/autoload.php"; | ||
|
||
* Include the namespaces you are going to use. | ||
|
||
To create any Microsoft Azure service client you need to use the **ServicesBuilder** class: | ||
|
@@ -102,15 +109,15 @@ There are four basic steps that have to be performed before you can make a call | |
|
||
use WindowsAzure\Common\ServiceException; | ||
|
||
* To instantiate the service client you will also need a valid connection string. The format is: | ||
|
||
* To instantiate the service client you will also need a valid connection string. The format is: | ||
|
||
* For accessing a live storage service (tables, blobs, queues): | ||
|
||
DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey] | ||
|
||
* For accessing the emulator storage: | ||
|
||
UseDevelopmentStorage=true | ||
|
||
* For accessing the Service Bus: | ||
|
@@ -221,9 +228,9 @@ The following are examples of common operations performed with the Blob serivce. | |
```PHP | ||
// OPTIONAL: Set public access policy and metadata. | ||
// Create container options object. | ||
$createContainerOptions = new CreateContainerOptions(); | ||
$createContainerOptions = new CreateContainerOptions(); | ||
|
||
// Set public access policy. Possible values are | ||
// Set public access policy. Possible values are | ||
// PublicAccessType::CONTAINER_AND_BLOBS and PublicAccessType::BLOBS_ONLY. | ||
// CONTAINER_AND_BLOBS: full public read access for container and blob data. | ||
// BLOBS_ONLY: public read access for blobs. Container data not available. | ||
|
@@ -277,7 +284,7 @@ try { | |
// List blobs. | ||
$blob_list = $blobRestProxy->listBlobs("mycontainer"); | ||
$blobs = $blob_list->getBlobs(); | ||
|
||
foreach($blobs as $blob) | ||
{ | ||
echo $blob->getName().": ".$blob->getUrl()."<br />"; | ||
|
@@ -317,7 +324,7 @@ try { | |
``` | ||
|
||
[Error Codes and Messages for Queues](http://msdn.microsoft.com/en-us/library/windowsazure/dd179446.aspx) | ||
|
||
|
||
### Add a message to a queue | ||
|
||
|
@@ -398,20 +405,20 @@ try { | |
``` | ||
|
||
## Service Bus Queues | ||
The current PHP Service Bus APIs only support ACS connection strings. You need to use PowerShell to create a new ACS Service Bus namespace at the present time. | ||
First, make sure you have Azure PowerShell installed, then in a PowerShell command prompt, run | ||
The current PHP Service Bus APIs only support ACS connection strings. You need to use PowerShell to create a new ACS Service Bus namespace at the present time. | ||
First, make sure you have Azure PowerShell installed, then in a PowerShell command prompt, run | ||
``` | ||
Add-AzureAccount # this will sign you in | ||
New-AzureSBNamespace -CreateACSNamespace $true -Name 'mytestbusname' -Location 'West US' -NamespaceType 'Messaging' | ||
``` | ||
If it is sucessful, you will get the connection string in the PowerShell output. If you get connection errors with it and the conection string looks like Endpoint=sb://..., change it to **Endpoint=https://...** | ||
|
||
### Create a Queue | ||
|
||
```PHP | ||
try { | ||
$queueInfo = new QueueInfo("myqueue"); | ||
|
||
// Create queue. | ||
$serviceBusRestProxy->createQueue($queueInfo); | ||
} catch(ServiceException $e){ | ||
|
@@ -454,14 +461,14 @@ try { | |
// Set the receive mode to PeekLock (default is ReceiveAndDelete). | ||
$options = new ReceiveMessageOptions(); | ||
$options->setPeekLock(true); | ||
|
||
// Receive message. | ||
$message = $serviceBusRestProxy->receiveQueueMessage("myqueue", $options); | ||
echo "Body: ".$message->getBody()."<br />"; | ||
echo "MessageID: ".$message->getMessageId()."<br />"; | ||
|
||
// *** Process message here *** | ||
|
||
// Delete message. | ||
$serviceBusRestProxy->deleteMessage($message); | ||
} catch(ServiceException $e){ | ||
|
@@ -476,7 +483,7 @@ try { | |
### Create a Topic | ||
|
||
```PHP | ||
try { | ||
try { | ||
// Create topic. | ||
$topicInfo = new TopicInfo("mytopic"); | ||
$serviceBusRestProxy->createTopic($topicInfo); | ||
|
@@ -524,7 +531,7 @@ try { | |
|
||
The primary way to receive messages from a subscription is to use a **ServiceBusRestProxy->receiveSubscriptionMessage** method. Received messages can work in two different modes: **ReceiveAndDelete** (the default) and **PeekLock** similarly to Service Bus Queues. | ||
|
||
The example below demonstrates how a message can be received and processed using **ReceiveAndDelete** mode (the default mode). | ||
The example below demonstrates how a message can be received and processed using **ReceiveAndDelete** mode (the default mode). | ||
|
||
```PHP | ||
try { | ||
|
@@ -533,8 +540,8 @@ try { | |
$options->setReceiveAndDelete(); | ||
|
||
// Get message. | ||
$message = $serviceBusRestProxy->receiveSubscriptionMessage("mytopic", | ||
"mysubscription", | ||
$message = $serviceBusRestProxy->receiveSubscriptionMessage("mytopic", | ||
"mysubscription", | ||
$options); | ||
echo "Body: ".$message->getBody()."<br />"; | ||
echo "MessageID: ".$message->getMessageId()."<br />"; | ||
|
@@ -549,17 +556,17 @@ try { | |
|
||
### Set-up certificates | ||
|
||
You need to create two certificates, one for the server (a .cer file) and one for the client (a .pem file). To create the .pem file using [OpenSSL](http://www.openssl.org), execute this: | ||
You need to create two certificates, one for the server (a .cer file) and one for the client (a .pem file). To create the .pem file using [OpenSSL](http://www.openssl.org), execute this: | ||
|
||
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem | ||
|
||
To create the .cer certificate, execute this: | ||
To create the .cer certificate, execute this: | ||
|
||
openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer | ||
|
||
### List Available Locations | ||
|
||
```PHP | ||
```PHP | ||
$serviceManagementRestProxy->listLocations(); | ||
$locations = $result->getLocations(); | ||
foreach($locations as $location){ | ||
|
@@ -579,11 +586,11 @@ $options->setLocation('West US'); | |
|
||
$result = $serviceManagementRestProxy->createStorageService($name, $label, $options); | ||
``` | ||
|
||
|
||
### Create a Cloud Service | ||
|
||
A cloud service is also known as a hosted service (from earlier versions of Microsoft Azure). The **createHostedServices** method allows you to create a new hosted service by providing a hosted service name (which must be unique in Microsoft Azure), a label (the base 64-endcoded hosted service name), and a **CreateServiceOptions** object which allows you to set the location *or* the affinity group for your service. | ||
A cloud service is also known as a hosted service (from earlier versions of Microsoft Azure). The **createHostedServices** method allows you to create a new hosted service by providing a hosted service name (which must be unique in Microsoft Azure), a label (the base 64-endcoded hosted service name), and a **CreateServiceOptions** object which allows you to set the location *or* the affinity group for your service. | ||
|
||
```PHP | ||
$name = "myhostedservice"; | ||
|
@@ -684,11 +691,11 @@ $streamingUrl = $originLocator->getPath() . '[Manifest file name]' . "/manifest" | |
|
||
###Manage media services entities | ||
|
||
Media services CRUD operations are performed through media services rest proxy class. It has methods like “createAsset”, “createLocator”, “createJob” and etc. for entities creations. | ||
Media services CRUD operations are performed through media services rest proxy class. It has methods like “createAsset”, “createLocator”, “createJob” and etc. for entities creations. | ||
|
||
To retrieve all entities list you may use methods “getAssetList”, “getAccessPolicyList”, “getLocatorList”, “getJobList” and etc. For getting single entity data use methods “getAsset”, “getJob”, “getTask” and etc. passing the entity identifier or entity data model object with non-empty identifier as a parameter. | ||
To retrieve all entities list you may use methods “getAssetList”, “getAccessPolicyList”, “getLocatorList”, “getJobList” and etc. For getting single entity data use methods “getAsset”, “getJob”, “getTask” and etc. passing the entity identifier or entity data model object with non-empty identifier as a parameter. | ||
|
||
Update entities with methods like “updateLocator”, “updateAsset”, “updateAssetFile” and etc. passing the entity data model object as a parameter. It is important to have valid entity identifier specified in data model object. | ||
Update entities with methods like “updateLocator”, “updateAsset”, “updateAssetFile” and etc. passing the entity data model object as a parameter. It is important to have valid entity identifier specified in data model object. | ||
|
||
Erase entities with methods like “deleteAsset”, “deleteAccessPolicy”, “deleteJob” and etc. passing the entity identifier or entity data model object with non-empty identifier as a parameter. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to the "Add requirement and install with one command" section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this operation applies for both cases. This library shouldn't be responsible to provide instructions on how install 3rd party tools. Take into account that the installation process can change in any moment, so it is better to point the users to the original source. Indeed, the recommended install process for Composer has been updated a short time ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the install process for Composer can change, and I don't want new users to be distracted by that, I want them just "Download composer.phar in your project root" and it will work. No need to configure it locally or globally. It will always work. Your instruction "php composer install " will only work when configured globally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, taking your concern into account I'll update all the references based on
composer.phar
being available at project's root.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the new install process states the following commands in order to ensure package consistency, security and system settings:
With your request, all of these checks and features will be lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is checking the integrity of the installer. if the users downloads composer.phar, they don't have this risk at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines obviously are checking the integrity of the installer, but the installer itself has a lot of other checks. You can take a look at the composer repo.
Whatever, downloading a file directly from a remote server without any check of integrity (like you are proposing) is very vulnerable for any kind of attack, like MITM by instance.
You can dive into this topic at this issue and take it just as an example.