Closed mcsouto closed 8 years ago
Is MyApp\PromoBundle\EndpointProvider
autoloadable by composer?
I think so
composer.json `"autoload": { "psr-4": { "MyApp\PromoBundle\": "src/MyApp/PromoBundle/", "MyApp\UserBundle\": "src/MyApp/UserBundle/", "MyApp\PromoBundle\EndpointProvider\":"src/MyApp/PromoBundle/EndpointProvider/", "AppBundle\": "src/AppBundle/"}, "files": [ "app/AppKernel.php" ] },
`
Do you get the same error if you run a script like the following in your project root?
<?php
require 'vendor/autoload';
var_dump(MyApp\PromoBundle\EndpointProvider::getEndPoint(['region' => 'us-east-1']));
First, I change "app\config\services.yml" with a value for the key "endpoint". If not, I cannot run the application.
aws_s3.client:
class: Aws\S3\S3Client
factory_class: Aws\S3\S3Client
factory_method: 'factory'
arguments:
options:
region: '%aws.region%'
version: '%aws.version%'
base_url: '%aws.base_url%'
endpoint: '%aws.base_url%'
endpoint_provider: MyApp\PromoBundle\EndpointProvider::getEndPoint
credentials:
key: %aws.key%
secret: %aws.secret%
Then, I could run the application and request test.1.php
<?php
require '../vendor/autoload.php';
var_dump(MyApp\PromoBundle\EndpointProvider::getEndPoint(['region' => 'us-east-1']));
Dump:
C:\_proyectos\TestAws\public\test.1.php:5:
array (size=1)
'endpoint' => string 'us-east-1.example.com' (length=21)
Thank you
I was able to reproduce this on OS X with PHP 5.6.17, where supplying '\Fully\Namespaced\Class::staticMethod'
produced a fatal error, whereas ['\Fully\Namespaced\Class', 'staticMethod']
did not. php.net states that both forms should work, but that does not seem to be the case on all systems.
The SDK invokes the endpoint provider by assigning it to a variable ($provider
) and calling $result = $provider($args);
, so I don't believe this is an issue with the SDK.
Arg! ok , now all works correctly . thanks all
I'm trying to use "endpoint_provider" . I have defined a service and a static function
` app\config\services.yml
services:
aws_s3.client: class: Aws\S3\S3Client factory_class: Aws\S3\S3Client factory_method: 'factory' arguments: options: region: %aws.region% version: %aws.version% base_url: %aws.base_url% endpoint_provider: MyApp\PromoBundle\EndpointProvider::getEndPoint credentials: key: %aws.key% secret: %aws.secret%`
`src\MyApp\PromoBundle\EndPointProvider.php <?php namespace MyApp\PromoBundle;
class EndpointProvider
{ public static function getEndPoint(array $params) { return ['endpoint' => $params['region'] . '.example.com']; } } `
composer.json { "require": { ... "aws/aws-sdk-php-symfony": "~1.0" } }
When I try to run the app always I get the same error:Can help me?
Regards