-
Notifications
You must be signed in to change notification settings - Fork 624
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
Comments
Hello @howardb3115, Did you happen to run I'm guessing With Best Regards, Elmer |
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. |
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. mailer_transport: sendmail
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
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, |
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 That's great feedback on the With Best Regards, Elmer |
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, |
Unfortunately, the 'composer update' died with a memory error: php ../composer/composer.phar update 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: 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. |
Having checked the link. I ran php -d memory_limit=-1 ../composer/composer.phar update Problem 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. |
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, |
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
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 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: [ErrorException] 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, |
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:
Mem: 1834 175 76 3 1581 1450 Thanks, |
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 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 |
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, |
Hello @howardb3115, To re-install SendGrid using composer: First, remove the SendGrid dependency. Then: composer require sendgrid/sendgrid ~5.5 With Best Regards, Elmer |
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, |
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 |
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 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 Installation failed, reverting ./composer.json to its original content. 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: [RuntimeException] 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 Installation failed, reverting ./composer.json to its original content. 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: [RuntimeException] 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. |
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. |
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 |
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
Installation failed, reverting ./composer.json to its original content. 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: [ErrorException] > 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"); 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, |
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 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
Writing lock file
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException] 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]
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] 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, |
Thank you for the update, I look forward to hearing the result of your next test. |
Thank you for your continued support with this issue.. I was successfully able to send emails using the demo php script shown on the
|
Thank you for taking the time to provide the final solution and having the patience to keep working with us! We appreciate your support! |
You're very welcome. :) |
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. 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, |
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 |
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. |
Hi @howardb3115, Have you created a pull request before? If not, I can guide you. |
No, I haven't done that in any of the github sites. You're help would be appreciated. Thank you, |
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 |
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:
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
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.
Run the testemail8.php script in the current version of Chrome.
Get the error and warning noted above.
"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:
The text was updated successfully, but these errors were encountered: