Where to save AWS Credentials file when using shared hosting? - php

I'm using Amazon's AWS PHP SDK and I installed composer on the following directory 'public_html/composer'. I am currently using shared hosting. However, I have access to the root.
When I tried using AWS's sample code I'm getting the following errors in my error_log:
Fatal error: Uncaught Aws\Exception\CredentialsException: Cannot read credentials from /.aws/credentials in /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Credentials/CredentialProvider.php:691 Stack trace: #0 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Credentials/CredentialProvider.php(424): Aws\Credentials\CredentialProvider::reject('Cannot read cre...') #1 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Middleware.php(121): Aws\Credentials\CredentialProvider::Aws\Credentials\{closure}() #2 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/RetryMiddleware.php(266): Aws\Middleware::Aws\{closure}(Object(Aws\Command), Object(GuzzleHttp\Psr7\Request)) #3 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Middleware.php(206): Aws\RetryMiddleware->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Request)) #4 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/StreamRequestPayloadMiddleware.php(83): Aws\Middleware::Aws\{closure}(Ob in /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Credentials/CredentialProvider.php on line 691
I created my credentials files as per AWS tutorial:
[default]
aws_access_key_id = 123456789
aws_secret_access_key = abcdefghijklm
The documentation states that I must save it in this location: ~/.aws/credentials
I tried many times to create the directory .aws/credentials however I get the same error. I tried also looking for the .aws file but I couldn't locate it except the one that I just created.
Given the above where should I place the credentials file? TIA

I also had the same issue of cannot read /.aws/credentials
Mentioning my solution here for reference:
This solution is tested in aws-php-sdk version 3.173:
CredentialProvider.php uses getenv('HOME')/.aws/credentials path to load the credentials from the file.
In my case (linux shared hosting) it was empty.
So I set it to desired value using:
putenv("HOME=/absolute/path/to/folder/containing/.aws/folder")

Related

Fatal error: Uncaught DocuSign\eSign\Client\ApiException: Error while requesting server, received a non successful HTTP code [302]

I created a demo app using the DocuSign Quickstart tool, but I get this error the moment my app attempts to use the "createEnvelope" function:
$results = $envelopeApi->createEnvelope($GLOBALS['DS_CONFIG']['ds_client_id'], $envelope_definition);
I'm sure it has to do with the Integration Key, but I don't know docusugn well enough to resolve the issue.
Any direction would be much appreciated.
Here's the full error:
Fatal error: Uncaught DocuSign\eSign\Client\ApiException: Error while requesting server, received a non successful HTTP code [302] with response Body: in C:\xampp\htdocs\embedded\vendor\docusign\esign-client\src\Client\ApiClient.php:344 Stack trace:
#0 C:\xampp\htdocs\embedded\vendor\docusign\esign-client\src\Api\EnvelopesApi.php(4117): DocuSign\eSign\Client\ApiClient->callApi('/v2.1/accounts/...', 'POST', Array, '{"documents":[{...', Array, '\\DocuSign\\eSign...', '/v2.1/accounts/...')
#1 C:\xampp\htdocs\embedded\vendor\docusign\esign-client\src\Api\EnvelopesApi.php(4023): DocuSign\eSign\Api\EnvelopesApi->createEnvelopeWithHttpInfo('xxxxxxxx-xxxx-x...', Object(DocuSign\eSign\Model\EnvelopeDefinition), NULL)
#2 C:\xampp\htdocs\embedded\public\index.php(117): DocuSign\eSign\Api\EnvelopesApi->createEnvelope('xxxxxxxx-xxxx-x...', Object(DocuSign\eSign\Model\EnvelopeDefinition))
#3 C:\xampp\htdocs\embedded\public\index.php(169): Example\make_envelope(Array) #4 {main} thrown in C:\xampp\htdocs\embedded\vendor\docusign\esign-client\src\Client\ApiClient.php on line 344
From the error trace, specifically the path "C:\xampp\htdocs\embedded\vendor\docusign\esign-client\src\Client\ApiClient.php", it looks like you deleted the outer folder.
I'm curious to know what you put in your C:\xampp\apache\conf\httpd.conf file. This setting in the httpd.conf file needs to match if you've deleted that folder:
DocumentRoot "C:/xampp/htdocs/Tally_Customer_Portal-php"
I would go through the quickstart guide on DocuSign. That way it will build out the code you need to get started. I would also make sure your token information is correct as well.
I lifted this code from a few different sources, and unfortunately it came with a few different problems. The one in this particular case was from the 'ds_client_id' value, which the QuickStart guide automatically assigns with your Integration Key. When running the createEnvelope function, you need your Account ID, not the Integration Key.

Unable to read the "../.dev.env" environment file in Dotenv.php:symfony

I want To run a symfony project in my computer but I get all times errors , and now I get this error and i didn't find any solution for my problem
Problem Failed to parse output as xml: Error on line 2: Content is not
allowed in prolog.. Command C:\xampp\php\php.exe
C:\xampp\htdocs\buzzaka\bin\console list --format=xml Output
Fatal error: Uncaught
Symfony\Component\Dotenv\Exception\PathException: Unable to read the
"C:\xampp\htdocs\buzzaka\bin/../.dev.env" environment file. in
C:\xampp\htdocs\buzzaka\vendor\symfony\dotenv\Dotenv.php:466 Stack
trace:
0 C:\xampp\htdocs\buzzaka\vendor\symfony\dotenv\Dotenv.php(51): Symfony\Component\Dotenv\Dotenv->doLoad(false, Array)
1 C:\xampp\htdocs\buzzaka\bin\console(38): Symfony\Component\Dotenv\Dotenv->load('C:\xampp\htdocs...')
2 {main} thrown in C:\xampp\htdocs\buzzaka\vendor\symfony\dotenv\Dotenv.php on line 466
If u move your file from the folder where it was created symfony will keep looking for it on this folder, i've went on autoload_runtime and changed on $runtime variable where the project is, just worked for me, lets see on the last composer dump what just happens haha
The error is quite explicit, do you have a file C:\xampp\htdocs\buzzaka\bin/../.dev.env ?
Well, you need to create one. As announced a little while ago, Symfony will now require a .env file per environment. As you are running your command in the dev environment, you need to create a .dev.env file.

Adding .env file to UserFrosting

I am facing a problem linking my MySQL database to Userfrosting. The guide gives an example of adding a .enr file to the directory so that Userfrosting can read the database credentials, but it doesn't seem to work.
Can someone give me an in-depth tutorial on how to do it?
Here is the error code when running install.php:
Could not connect to the database '#/'. Please check your database
configuration and/or google the exception shown below:
Exception: SQLSTATE[HY000] [2002] No such file or directory
Trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/myUserFrostingProject/migrations/install.php(63): PDO->__construct('mysql:host=;dbn...', NULL, NULL)
#1 {main}
For MAMP, the DB_HOST needs to be set to 127.0.0.1 instead of localhost. It's probably the same case with XAMPP. There's already an open pull request regarding this. See https://github.com/userfrosting/UserFrosting/pull/659.

Pushing a Zend Application into Amazon EC2 Instance

I'm trying to push a zend application onto an amazon EC2 instance.
I have set up my Zend application on the server and have set up the httpd conf.
When I try to access my website through the browser, I get the following message printed:
bootstrap() ->run();
I have followed all the standard procedures and am able to see static HTML files. But when I try to access PHP files, I see a blank page.
I checked the log files but those do not return any errors.
Any idea why I'm facing this issue.
Update:
I updated my php.ini file with the zend library include_path.
Now I'm faced with the following error:
Fatal error: Uncaught exception 'Zend_Application_Bootstrap_Exception' with message 'Resource
matching "Jquery" not found' in /usr/share/php/libzend-framework-php/Zend/Application/Bootstrap
/BootstrapAbstract.php:694 Stack trace: #0 /usr/share/php/libzend-framework-php/Zend/Application
/Bootstrap/BootstrapAbstract.php(626):
Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('Jquery') #1 /usr/share/php/libzend-
framework-php/Zend/Application/Bootstrap/BootstrapAbstract.php(586):
Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #2 /usr/share/php/libzend-framework-
php/Zend/Application.php(355): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap(NULL) #3
/var/www/html/urban-chatter/public/index.php(29): Zend_Application->bootstrap() #4 {main} thrown in
/usr/share/php/libzend-framework-php/Zend/Application/Bootstrap/BootstrapAbstract.php on line 694
Solved:
I copied the zend library from my system onto the server and changed the include_path to the new library in php.ini file and everything started working. I think there was some compatibility issues when I used another version of zend library.

Mirror API database access issue

I just installed the Google mirror API. I have everything setup except after I log in to the API, I get this error message:
Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\mirror-client.php on line 33
Fatal error: Uncaught exception 'Exception' with message 'Unable to open database: unable to open database file' in C:\xampp\htdocs\util.php:62 Stack trace: #0 C:\xampp\htdocs\util.php(62): SQLite3->__construct('/tmp/database.s...') #1 C:\xampp\htdocs\util.php(26): init_db() #2 C:\xampp\htdocs\oauth2callback.php(41): store_credentials('107736579479351...', '{"access_token"...') #3 {main} thrown in C:\xampp\htdocs\util.php on line 62
It seems that the API can't create the database or do I need to create it?
I tried making a folder and database as it is set up in the config.php file "tmp/database.sqlite" but no luck.
Any ideas?
I figured out that you had to make your own database for it to work.
It can mean that the directory/folder you placed the sqlite file in (and the file itself) does not have the correct permissions. You need to make sure both the folder and the file have read and write permissions. The xampp directory in my environment has read/write permissions. You might want to place your database there, at least for testing purposes.
Note: The /tmp directory as mentioned in "/tmp/database.sqlite" is a Linux/Mac directory. You may want to change the value of $sqlite_database in the config.php file to point to a file in a Windows directory.

Categories