Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing SendGrid-PHP using Composer -- Issues installing and using this API #404

Closed
howardb3115 opened this issue Jun 21, 2017 · 30 comments
Labels
status: help wanted requesting help from the community type: question question directed at the library

Comments

@howardb3115
Copy link

Issue Summary

I was directed here after working with James, one of the SendGrid Support Techs.

I am trying to install the current version of the SendGrid PHP API, and have made the necessary changes to my composer.json file as directed in your instructions that are here in this site, specifically:

"require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.8.*",
    "doctrine/orm": "^2.4.8",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "google/recaptcha": "~1.1",
    **"sendgrid/sendgrid": "~5.5"**
},

I'm using a modified version of your Hello Email script, called testemail8.php, where I've changed the $from and $to variables to have the values I need in order to actually get an email in my personal email. I have a SendGrid API key from when I initially tried to use the SendGrid Web-API version 5.1 after joining SendGrid.

However, when I run my version of the Hello Email script I get a warning and an error:

Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in /var/www/vhosts/symfony2/web/testemail8.php on line 3

Fatal error: require(): Failed opening required 'vendor/autoload.php' (
testemail8.TXT) in /var/www/vhosts/symfony2/web/testemail8.php on line 3

Line three of my testemail8.php script is:

require 'vendor/autoload.php';

testemail8.TXT

Steps to Reproduce

  1. Follow the installation instructions listed at this site (https://github.com/sendgrid/sendgrid-php),
    including the modification of the composer.json file, the creation of the sendgrid.env file, and the creation of a test script called testemail8.php that is based on the example script on this site.

  2. Run the testemail8.php script in the current version of Chrome.

  3. Get the error and warning noted above.

  4. "Why do you consider this to be a bug?" & "What do you expect to happen instead?
    ":
    The instructions provided for the installation and testing do not appear to actually download and install the API package, evidenced by the messages received when running the require statement in my testemail8.php script.

Technical details:

  • sendgrid-php I assume its version 5.5, from the line in the composer.json file.
  • PHP Version: 5.6.3
@thinkingserious thinkingserious added status: help wanted requesting help from the community type: question question directed at the library labels Jun 21, 2017
@thinkingserious
Copy link
Contributor

Hello @howardb3115,

Did you happen to run composer install?

I'm guessing vendor/autoload.php does not exist in your project. When you run composer install it will exist.

With Best Regards,

Elmer

@caseyw
Copy link
Contributor

caseyw commented Jun 21, 2017

Also, note that you may be trying to load the file from a location where the path isn't set.

That would mean the path "vendor/autoload.php" may be taken literal, and your test file cannot see it. If you're running a symfony project that may mean you're a level higher in like "web" for example, and its looking for "vendor/autoload.php" in "web".

I'm sure you'll find the solution now that you're here.

@howardb3115
Copy link
Author

Thank you Elmer and CasyW,

Yes, I did run composer install, but only digging into the github php-HTTP-Client, which I have not installed, but vendor/autoload.php existed before running this command.

However, the result of running composer install is that it also removed a bunch of database setting from my parameters.yml file. I was lucky because I had a before version of the file and was able to put back in the database settings, but I also got this message:

Some parameters are missing. Please provide them.

I have no idea what parameters are missing.
When I compare the 'before' and 'after' versions, I see that the changes were that the setting for sendmail were removed:

mailer_transport: sendmail

mailer_transport:        smtp
mailer_host:             rs42020.mailgun.org
mailer_user:             postmaster
mailer_password:         <password>

But as you can see these were the settings for MailGun, which I'm no longer using, but nothing was put in to replace these entries for SendGrid.

Here is the full composer install output:

php ../composer/composer.phar install

You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files

Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
Some parameters are missing. Please provide them.
*** End of Output ***

CaseyW. I'm not understanding your comment, but it seems like you're saying that I'm running the testemail8.php in the wrong directory. I am running it from the web directory and vendor/autoload.php does exist, where vendor is in the parent directory of web. This doesn't seem to be a problem for the web-application that I'm developing, and in which SendGrid will be used after it is installed and running.

By the way, if composer install is needed, then it might be a good idea to also indicate that in the installation instructions.

Thanks again,
Ron Brown

@thinkingserious
Copy link
Contributor

Hello @howardb3115,

Since you are using the Web API directly, you do not need to setup the mailer_transport settings. If you wish to use our SMTP Relay instead of the Web API, you can find the settings here.

Based on the output above, it looks like you need to run:

php ../composer/composer.phar update

Something else to try:

Replace require 'vendor/autoload.php'; with require '[full path to]/vendor/autoload.php';

That's great feedback on the composer install step. Right now, we simply link to the Composer web page here with the assumption that the user will be familiar with installation via composer. Would you suggest that we include the Composer setup steps in that section as well?

With Best Regards,

Elmer

@howardb3115
Copy link
Author

Elmer,

Thank you for that information. I believe that I want to use the Web API directly, because this will give me access to all of the SendGrid features, including the eventual use of templates for mass-mailings of a newletter to our suscribers.

After running the php ../composer/composer.phar install command and having it mess up the database settings in my parameters.yml file, I'm a bit nervous about what other damage it might have happened, but since I have a backup of my system from before doing the 'composer install', I am running the 'composer update' (php ../composer/composer.phar update) as you recommended.

As to the require '[full path to]/vendor/autoload.php' - why wouldn't the require 'vendor.autoload.php' work? It seems to work properly when I use it in the web-app that I'm developing? The app_dev.php file that 'kicks-off' my Symfony2 web-app is in the web directory -- the same directory as the testemail7.php script I know that the require 'vendor.autoload.php' works for my web-app, because after running the 'composer install', yesterday, and having it remove some of the database settings from my parameters.yml file, my web-app gave me a ton of errors that went away after I manually pasted them back in.

As to what you might do concerning using compass instructions, Yes, because if I should run the 'composer install' after modifying my composer.json file, then instead of assuming that we all know that, Actually, I thought that the 'require' statement automatically resolved the download and installation, because the error indicated that there was a streaming failure, which I took to mean that the download failed for some reason, a NOOBIE error on my part. For all us NOOBIES, having the 'composer install' as an explicit step in the instructions and also in the SendGrid quick set up guide, would be helpful. Also, your point about adding a link to using Composer would be helpful, too, something like 'For additional information about Composer, please see .'.

The instructions also say that the API can be manually installed by downloading the zip file and 'installing' it, but it doesn't say how to 'install' it, nor does the readme.md file in the archive. If there is something that needs to be done after downloading the archive and extracting the contents then that too really shouldn't be assumed. If the act of downloading and extracting the content is all that needs to be done, then at least to me saying 'and install' is confusing.

Finally, a small nit, but at the end of several PHP scripts, showing how to use SendGrid to send emails, I see that the closing ?> characters are omitted. This may be acceptable, but I suggest that including them helps to indicate that the script is not missing any lines. Besides, saving to lines for brevity isn't much of a savings. :)

Thanks again,
Ron Brown

@howardb3115
Copy link
Author

Unfortunately, the 'composer update' died with a memory error:

php ../composer/composer.phar update
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 32 bytes) in phar:///var/www/vhosts/composer/composer.phar/src/Composer/DependencyResolver/Rule.php on line 57

Call Stack:
0.0082 435104 1. {main}() /var/www/vhosts/composer/composer.phar:0
0.0085 436824 2. require('phar:///var/www/vhosts/composer/composer.phar/bin/composer') /var/www/vhosts/composer/composer.phar:24
0.0908 4408944 3. Composer\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/bin/composer:43
0.0965 4800016 4. Symfony\Component\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Console/Application.php:104
0.0987 4938080 5. Composer\Console\Application->doRun() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:123
0.4847 10600328 6. Symfony\Component\Console\Application->doRun() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Console/Application.php:231
0.4850 10600824 7. Symfony\Component\Console\Application->doRunCommand() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:192
0.4851 10601400 8. Symfony\Component\Console\Command\Command->run() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:847
0.4892 10606872 9. Composer\Command\UpdateCommand->execute() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Command/Command.php:259
0.4949 11036352 10. Composer\Installer->run() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Command/UpdateCommand.php:174
0.4986 11181128 11. Composer\Installer->doInstall() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Installer.php:216
0.7565 12133112 12. Composer\DependencyResolver\Solver->solve() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Installer.php:461
0.7568 12143888 13. Composer\DependencyResolver\RuleSetGenerator->getRulesFor() phar:///var/www/vhosts/composer/composer.phar/src/Composer/DependencyResolver/Solver.php:214
399.7393 1050657920 14. Composer\DependencyResolver\RuleSetGenerator->addRulesForPackage() phar:///var/www/vhosts/composer/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php:330
402.6376 1058359632 15. Composer\DependencyResolver\RuleSetGenerator->createConflictRule() phar:///var/www/vhosts/composer/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php:246
402.6376 1058360256 16. Composer\DependencyResolver\Rule->__construct() phar:///var/www/vhosts/composer/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php:126

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.

I'm going to check that link.

@howardb3115
Copy link
Author

Having checked the link. I ran php -d memory_limit=-1 ../composer/composer.phar update
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- sendgrid/sendgrid 5.5.1 requires php >=5.6 -> your PHP version (5.6.30) overridden by "config.platform.php" version (5.3.9) does not satisfy that requirement.
- sendgrid/sendgrid 5.5.0 requires php >=5.6 -> your PHP version (5.6.30) overridden by "config.platform.php" version (5.3.9) does not satisfy that requirement.
- Installation request for sendgrid/sendgrid ~5.5 -> satisfiable by sendgrid/sendgrid[5.5.0, 5.5.1].

You have new mail in /var/spool/mail/root

sendgrid/sendgrid 5.5.1 requires php >=5.6 -> your PHP version (5.6.30) overridden by "config.platform.php" version (5.3.9) does not satisfy that requirement.

Apparently, my version of PHP is being limitet to 5.3.9, I'll talk with my system admin about removing the override.

@howardb3115
Copy link
Author

My system admin said that he couldn't find the config.platform.php file talked about in the Problem 1 message, does the PHP.ini contain anything limiting the PHP version, and we only have one PHP.ini file in the system.

When I run phpinfo.php, I see that my version is 5.6.30, and nothing in the phpinfo report says anything about being downgraded to 5.3.9.

With all of this in mind, what should I do next?

I'd kind of like keeping composer rather than going to manually installing each of the packages, especially since I don't know how to do that.

Thanks,
Ron Brown

@howardb3115
Copy link
Author

I got another memory error when I ran the 'composer update' command again (actually php -d memory_limit=-1 ../composer/composer.phar update).

The output was:

You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Loading composer repositories with package information
Updating dependencies (including require-dev)

PHP Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php on line 957
PHP Stack trace:
PHP 1. {main}() /var/www/vhosts/composer/composer.phar:0
PHP 2. require() /var/www/vhosts/composer/composer.phar:24
PHP 3. Composer\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/bin/composer:43
PHP 4. Symfony\Component\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Console/Application.php:104
PHP 5. Symfony\Component\Console\Application->renderException() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:130
PHP 6. Symfony\Component\Console\Application->getTerminalWidth() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:651
PHP 7. Symfony\Component\Console\Application->getTerminalDimensions() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:718
PHP 8. Symfony\Component\Console\Application->getSttyColumns() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:757
PHP 9. proc_open() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:957

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php on line 957

Call Stack:
0.0118 434928 1. {main}() /var/www/vhosts/composer/composer.phar:0
0.0121 436648 2. require('phar:///var/www/vhosts/composer/composer.phar/bin/composer') /var/www/vhosts/composer/composer.phar:24
0.1053 4408664 3. Composer\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/bin/composer:43
0.1111 4799536 4. Symfony\Component\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Console/Application.php:104
1266.1032 347778104 5. Symfony\Component\Console\Application->renderException() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:130
1266.1146 347778592 6. Symfony\Component\Console\Application->getTerminalWidth() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:651
1266.1146 347778744 7. Symfony\Component\Console\Application->getTerminalDimensions() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:718
1266.1178 347778840 8. Symfony\Component\Console\Application->getSttyColumns() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:757
1266.1184 347780800 9. proc_open() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:957

[ErrorException]
proc_open(): fork failed - Cannot allocate memory

I'm asking my system admin to look into adding more memory, but I don't know how much to ask for. Any idea?

Thanks again,
Ron Brown

@howardb3115
Copy link
Author

The composer trouble shooting guide at https://getcomposer.org/doc/articles/troubleshooting.md says that one cause of not being able to run the fork operation is that there isn't any swap space configured and to test for this with the 'free -m' command. When I did this, the result showed that there is actually swap space, but I'm guessing that it wasn't enough. Unfortunately, the output from the 'composer update' (see the actual command in my previous comment) didn't say how much more memory or swap space was needed. However, I'm thinking that the increase is temporary, just while the 'composer update' is running. I've put this issue to my system admin for as resolution.

Here is the actual 'free -m' output:

          total        used        free      shared  buff/cache   available

Mem: 1834 175 76 3 1581 1450
Swap: 3071 526 2545
You have new mail in /var/spool/mail/root

Thanks,
Ron Brown

@thinkingserious
Copy link
Contributor

Hello @howardb3115,

I do not know enough about your application to suggest how much memory you need, but perhaps these resources might help:

composer/composer#945
https://stackoverflow.com/questions/18116261/php-composer-update-cannot-allocate-memory-error-using-laravel-4

Regarding config.platform.php, perhaps this may be the issue? https://stackoverflow.com/questions/35538071/symfony2-composer-your-php-version-5-6-18-overriden-by-config-platform-php

With Best Regards,

Elmer

@howardb3115
Copy link
Author

Hello,

After spending two days trying to get 'composer update' and 'composer install' to complete successfully, trying different options such as -d memory_limit=-1 and -d memory_limit=2G, I am no longer getting the fork error, but now getting a kill suicide.

By the way running 'composer update' created a lot of temp files and after several attempts, filled up almost all of my server's hard drive, which had over 15GB of free space! My system administrator deleted all of these before running the last 'composer update' attempt, which also failed with a kill suicide.

Since composer manages all of the other packages fine, except SendGrid, is there a way to just tell composer to install the SendGrid php api package without going through all of the other already working packages?

If not then ...

Would someone please give me the complete SendGrid php api manual installation instructions. That is exactly what I need to do after I do after downloading the package: do I unzip the file, should I put the unzipped directory in my Symfony2 vendors directory, what command do I need to run from the command line. So far all I've seen is download the file and install it -- no details on how to do that.

Is there any problem letting composer continue to manage the already installed packages other than SendGrid, and have SendGrid as the only manually installed package?

Thank you,
Ron Brown

@thinkingserious
Copy link
Contributor

Hello @howardb3115,

To re-install SendGrid using composer:

First, remove the SendGrid dependency.

Then:

composer require sendgrid/sendgrid ~5.5

With Best Regards,

Elmer

@howardb3115
Copy link
Author

Sorry, what about the updates and installs that have been blowing up?

Are you saying that I should I remove the sendgrid/sendgrid ~5.5 from the composer.json file and then run the 'composer require sendrid/sendgrid ~5.5' command from the command line?

Thank you,
Ron Brown

@thinkingserious
Copy link
Contributor

Hello @howardb3115,

I'm not sure what is happening with the updates and installs blowing up. I have not encountered that issue before, nor have I seen it reported here.

After researching the issue, I came to the conclusion, your best bet is to re-install. That seems to have worked for others having install issues with Symfony 2.

My suggestion is to follow the steps outlined in my previous comment. I'm not familiar with Symfony 2, so I pointed you to a uninstall article that appears to make sense and was selected as a correct answer on Stack Overflow. The same is true for the installation, that advice was the result of researching what worked for others.

With Best Regards,

Elmer

@howardb3115
Copy link
Author

Thank you Elmer for getting back to me.

I removed the lines from my sendgrid entries in the composer.json and parameters.yml files. The config.yml file doesn't make reference to the sendgrid entries that were removed from the other files.

Then I ran the php ../composer/composer.phar require sendgrid/sendgrid ~5.5 command from the command line as root and got the following:

**You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 72 bytes) in phar:///var/www/vhosts/composer/composer.phar/src/Composer/DependencyResolver/Rule.php on line 60

Call Stack: ..

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors..**

So I ran: php -d memory_limit=2G ../composer/composer.phar require sendgrid/sendgrid ~5.5 and got this output:

**You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.
The disk hosting /root/.composer is full, this may be the cause of the following exception

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php on line 957

Call Stack:
0.0136 435480 1. {main}() /var/www/vhosts/composer/composer.phar:0
0.0138 437200 2. require('phar:///var/www/vhosts/composer/composer.phar/bin/composer') /var/www/vhosts/composer/composer.phar:24
0.1116 4409344 3. Composer\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/bin/composer:43
0.1179 4800344 4. Symfony\Component\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Console/Application.php:104
1053.3390 349925288 5. Symfony\Component\Console\Application->renderException() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:130
1053.3488 349925840 6. Symfony\Component\Console\Application->getTerminalWidth() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:651
1053.3488 349925992 7. Symfony\Component\Console\Application->getTerminalDimensions() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:718
1053.3511 349926088 8. Symfony\Component\Console\Application->getSttyColumns() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:757
1053.3522 349928048 9. proc_open() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:957

[RuntimeException]
/var/www/vhosts/symfony2/vendor/sendgrid/php-http-client does not exist and could not be created.**

Two things stick out:

The disk hosting /root/.composer is full, this may be the cause of the following exception

and

/var/www/vhosts/symfony2/vendor/sendgrid/php-http-client does not exist and could not be created.

So I cleaned out the /root/.composer/cache directory and ran the php -d memory_limit=2G ../composer/composer.phar require sendgrid/php-http-client ~3.7 command, but it dies due to there not being enough drive space.

**You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Writing /root/.composer/cache/repo/https---packagist.org/provider-phpdocumentor$reflection-docblock.json into cache failed after 0 of 27257 bytes written, only 0 bytes of free space available
Writing /root/.composer/cache/repo/https---packagist.org/provider-phpdocumentor$type-resolver.json into cache failed after 0 of 13654 bytes written, only 0 bytes of free space available
Writing /root/.composer/cache/repo/https---packagist.org/provider-symfony$workflow.json into cache failed after 0 of 118162 bytes written, only 0 bytes of free space available

Installation failed, reverting ./composer.json to its original content.
The disk hosting /root/.composer is full, this may be the cause of the following exception

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php on line 957

Call Stack:
0.0110 435448 1. {main}() /var/www/vhosts/composer/composer.phar:0
0.0112 437168 2. require('phar:///var/www/vhosts/composer/composer.phar/bin/composer') /var/www/vhosts/composer/composer.phar:24
0.0958 4409056 3. Composer\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/bin/composer:43
0.1016 4800104 4. Symfony\Component\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Console/Application.php:104
1576.3182 349096448 5. Symfony\Component\Console\Application->renderException() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:130
1576.3466 349097000 6. Symfony\Component\Console\Application->getTerminalWidth() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:651
1576.3466 349097152 7. Symfony\Component\Console\Application->getTerminalDimensions() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:718
1576.3477 349097248 8. Symfony\Component\Console\Application->getSttyColumns() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:757
1576.3573 349099208 9. proc_open() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:957

[RuntimeException]
/var/www/vhosts/symfony2/vendor/sendgrid/php-http-client does not exist and could not be created.**

At this point it looks like I need to manually install both the sendgrid/php-http-client and sendgrid/sendgrid unless you have any other ideas.

@howardb3115
Copy link
Author

I found that my system's primary hard drive is showing 100% used, even though I've spent two hours deleting hundreds of files, some of which were quite large. I'm having my system administrator look into why the space that should have been freed when the files were deleted isn't showing when I use the df command. Perhaps when this is resolved I'll be able to run the composer commands, after all.

@thinkingserious
Copy link
Contributor

Hello @howardb3115,

If you do need to install without composer, you can download the files here, and then ensure your app require's SendGrid as follows:

require("path/to/sendgrid-php/sendgrid-php.php");

Thanks!

With Best Regards,

Elmer

@howardb3115
Copy link
Author

Unfortunately, even after 18GB of diskspace were freed, I can not install the prerequisit sendgrid/php-http-client package.

**php -d memory_limit=2G ../composer/composer.phar require sendgrid/php-http-client ~3.7

You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Installing sendgrid/php-http-client (3.7.0)
    Downloading: 100%

Installation failed, reverting ./composer.json to its original content.
The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php on line 957

Call Stack:
0.0159 435448 1. {main}() /var/www/vhosts/composer/composer.phar:0
0.0163 437168 2. require('phar:///var/www/vhosts/composer/composer.phar/bin/composer') /var/www/vhosts/composer/composer.phar:24
0.1181 4409056 3. Composer\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/bin/composer:43
0.1238 4800104 4. Symfony\Component\Console\Application->run() phar:///var/www/vhosts/composer/composer.phar/src/Composer/Console/Application.php:104
883.4065 349477688 5. Symfony\Component\Console\Application->renderException() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:130
883.4142 349478176 6. Symfony\Component\Console\Application->getTerminalWidth() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:651
883.4142 349478328 7. Symfony\Component\Console\Application->getTerminalDimensions() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:718
883.4155 349478424 8. Symfony\Component\Console\Application->getSttyColumns() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:757
883.4160 349480384 9. proc_open() phar:///var/www/vhosts/composer/composer.phar/vendor/symfony/console/Application.php:957

[ErrorException]
proc_open(): fork failed - Cannot allocate memory**

> If you do need to install without composer, you can download the files here, and then ensure your app require's SendGrid as follow

So I just download the sendgrid/php-http-client and sendgrid/sendgrid package, unzip them, place them anywhere I want, and reference them with their own require statements in my code at the top of the script were I have other require api statements as follows:

require("path/to/sendgrid-php/sendgrid/php-http-client.php");
require("path/to/sendgrid-php/sendgrid-php.php");

Can these api package directories go in the vendors directory with all of the other third-party packages that composer manages?

Is there documentation for either of these api packages that spells out all of the manual installation details?

Thank you,
Ron Brown

@howardb3115
Copy link
Author

Latest update - 18GBs of drive space were freed and I disabled xdebugger, sort of, by setting the enabling options in the 15-xdebug.ini file to zeros:

xdebug.remote_enable=0
xdebug.profiler_enable=0

I say sort of because while setting these options to zeros, seems to be the normal way to disable the xdebugger, composer says that it's on.

Then I ran the 'conposer require sendgrid/sendgrid `5.5 command with a memory limit of 3 gigs:

php -d memory_limit=3G ../composer/composer.phar require sendgrid/sendgrid ~5.5

**You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Installing sendgrid/php-http-client (3.7.0)
    Downloading: 100%

  • Installing sendgrid/sendgrid (5.6.1)
    Downloading: 100%

Writing lock file
Generating autoload files

Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "database_server_version".

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception

Installation failed, reverting ./composer.json to its original content.

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "database_server_version".**

The encouraging thing is that unlike all of the other attempts to run this command, I'm seeing that the sendgrid/sendgrid-php and sendgrid/php-http-client were both being downloaded.

The discouraging thing is that I'm now getting an error about the "database_server_version":

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "database_server_version"

The odd thing is that this is a new error and the old one about the "database_driver", which previously occurred, doesn't show any. By the way, neither of these option values have been changed since they were created just after Symfony 2 was installed.

The other good sign is that unlike when I tried to use the 'composer install' or 'compose update' commands, even though the 'composer require ...' command dies with the "database_server_version" error, my web-application start properly!

What I still need to do is verify that the sendgrid php api is actually loaded and working when I run a script containing the require( "vendors/autoload.php" ) command. I'll post here when I know the answer.

Thank you,
Howard Brown

@thinkingserious
Copy link
Contributor

Thank you for the update, I look forward to hearing the result of your next test.

@howardb3115
Copy link
Author

Thank you for your continued support with this issue.. I was successfully able to send emails using the demo php script shown on the tab. Even though the 'composer require ...' command that you suggested displayed a 'non-existent parameter "database_server_version"' error, it still downloaded and installed the sendgrid/sendgrid-php api and sendgrid/php-http-client packages, which I was then able to verify by successfully sending a test email using your demo script.

To do this I had to turn off the xdebugger. The message about the performance impact, while true, didn't fully alert me to the additional memory and diskspace consumed by the debugger, and appeared to be needed to install these packages. I also had to clear out the xdebugger log files that were piling-up after all of the failed composer install/update/require attempts. And finally, the use of memory_limit=3G rather than the memory_limit=-1.

Thanks again,
Howard Brown

@thinkingserious
Copy link
Contributor

Thank you for taking the time to provide the final solution and having the patience to keep working with us! We appreciate your support!

@howardb3115
Copy link
Author

You're very welcome. :)

@howardb3115
Copy link
Author

Thanks for the examples shown on this site's <code> tab.

I'd like to offer an alternative that solved a couple of problems that I ran into when I tried to apply pieces of your example code to my real world code where I wanted to use SendGrid to send emails out to my users to confirmation account registrations. password changes, and alerts.

Your examples ran fine when I tried them out for myself, but then I found a possible source of confusion when I integrated parts of your code into my Symfony2 web-app -- specifically, the use of namespace statement and the unqualified SendGrid classes, i.e., Mail, Email, Personalization, etc., caused compilation errors.

To get around this, I changed the namespace statement to a use statement and added the SendGrid/ qualifier before the various SendGrid classes where they were being instantiated. I then made these same changes in a modified version of your example code, which I've attached, here.

testapi.TXT

Both Symfony 2 and PHP do allow for multiple namespaces statements within a single script, but I found that to do this made my code more complicated, so instead I just used the use statement to make my code 'see' the SendGrid items. However, the simpler form of the use statement gave me a warning in my modified version of your example code, so I changed it to a use as statement, and that eliminated the warning. Then I used the qualified *SendGrid* qualifiers before all of the SendGrid classes and eliminated those errors, too.

Thank again,
Howard Brown

@thinkingserious
Copy link
Contributor

This feedback is awesome Howard!

Would you mind putting your observations/sample code here (with a PR) under a heading "Symfony 2 Integration"?

If you do not wish to make a PR, no worries, I would go ahead and add a similar example.

With Best Regards,

Elmer

@howardb3115
Copy link
Author

I would be happy to post my last comments and my sample code in the PR area, but I don't understand what is being asked when it wants me to compare versions.

@thinkingserious
Copy link
Contributor

Hi @howardb3115,

Have you created a pull request before? If not, I can guide you.

@howardb3115
Copy link
Author

No, I haven't done that in any of the github sites. You're help would be appreciated.

Thank you,
Howard Brown

@thinkingserious
Copy link
Contributor

@howardb3115,

Please complete this course and reach back out at the end and I will walk you through how to make the change step by step: https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github

With Best Regards,

Elmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: question question directed at the library
Projects
None yet
Development

No branches or pull requests

3 participants