I've been able to deploy an example Symfony 3 app to a Google AppEngine Flexible PHP app following the example here. I then added the CloudSQL APIs to the project and the entries in app.yaml so when I SSH into an instance, I can see the MySQL socket in /cloudsql/. I then added the Doctrine bundles to the Symfony project, setup a couple models, etc., tested locally successfully, and tried to redeploy the app to Google.
When the deploy process runs composer, it's running the symfony-scripts entries defined in composer.json. Some of those routines need to access the database apparently but that's failing. I'm getting An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory errors from the clearCache script. If I remove that entry from composer.json and retry, I get the same error from the next script.
I'm beginning to think that the socket that connects to the database may not be configured during the app deploy process. Has anyone tried to do something like this before and gotten it to work?
Answering my own question...
Why does a composer update need access to the database
Adding server_version: 5.7 under doctrine dbal in my app/config/config.yml fixed this. It no longer tries to connect to the database during composer install and the app deploys now.
Related
wondering if someone can maybe help me out a bit.
I have been working on a project that is a symfony2 web app running on Microsoft azure. it was all working great! i have my code being pulled in from git and i can easily push and update the site.
I then started working on Logins, nothing fancy, i was playing around with HTTP_BASIC athuentication and had it working after following the docs here
http://symfony.com/doc/current/book/security.html
I had a few users and i was pretty happy as id never done this before, my aim down the line is to use doctrine and databases etc but for the moment this will do.
so i had it working locally then i pushed to my branch. and boom 500 error. now i'm not sure what I've done and I've already done a bit of research, but nothing has really helped?
I read somewhere that by removing all the .htaccess files would be a fix, but no avail. the error that i'm getting is just a google 500 error and not a symfony error which makes me that I've really messed it up!
i could roll back to a previously working commit but id lose a lot of work on the front end side, but its confusing how everything is working absolutely fine locally but not on the server... please ask me any questions that could help you help me i guess!
help would be great. also, im a junior!
I built an clear symfony application, configured the security system with HTTP_BASIC authentication on local, and deployed to Azure Web app via GIT. I didn’t have 500 internal error.
So I suspect that there are some errors in the application.
Usually, when we deploy symfony applications to Azure via GIT, there several files and folders will not be updated with the application which may cause the application lack of dependent packages, we can check the list in .gitignore file in root directory.
Login on KUDU console site of your Azure Web App, the URL should be: https://<your _site_name>.scm.azurewebsites.net/DebugConsole, run the following commands in cmdlet:
cd site\wwwroot
(if you do not have composer.phar file in your project)
curl -sS https://getcomposer.org/installer | php
php composer.phar install
It will install the dependences and clear the cache.
Furthermore, we can check whether the application can run in dev mode, visit URL: http://<your _site_name>.azurewebsites.net/web/app_dev.php, if it works fine in dev mode, but rise an error 500 in prod mode known as “app.php”, we should manually clear the production cache:
Login on KUDU console site, and run php app/console cache:clear --env=prod.
If you get a [Symfony\Component\Filesystem\Exception\IOException] exception, you can manually delete app\cache\prod folder and run the command again.
Also, we can check the detail error messages in dev.log and prod.log in app\logs folder.
Beside doing file operations in KUDU console site, we can use WebMatrix on Windows to remote our sites on Azure.
I have a similar question to Pushing to an existing AWS Elastic Beanstalk application from the command line and Git pushes entire project even if few files are changed. AWS but did not see the answer I am looking for.
There have been comments about the confusing changes to Amazon's documentation because different versions of the documentation state they are the latest when some functions have actually been replaced and I think a new question is warranted now.
I used the Deploying a Symfony2 Application to AWS Elastic Beanstalk guide to setup my dev app and it works great. After I make several changes and want to update the aws app, I use git aws.push which creates a new version of my app and restarts the server.
I do not have my configuration files finalized (this is just a dev app) and need to manually run several commands on the remote server before my app can be viewed. For very minor temporary changes, I connected to the remote server via ssh and edited the php files directly which works fine. This way the server does not need to be restarted because everyimt I use git aws.push the server restarts. I would like to have a method to update those files using git without restarting the entire server/app.
Main question - Is there anyway I can push only the files that were changed in the recent commit and not have the server restart?
Side question for new aws commands - Should I use the eb commands Getting Started with EB CLI 3.x and use eb deploy instead of the git command?
No, currently there is no scenario where Elastic Beanstalk pulls changes without reinitiating and restarting server.
You can try to write your own workaround for that purpose, but you
will need to mention files that need to be updated manually and be
sure that files will be delivered to each EB instance. If you are
pushing from windows don't forget to convert line ending dos2unix.
eb deploy is a canonical command for aws.push
If you experience "full upload" issue instead of sending "only changes", please read my fresh answer here:
Elastic Beanstalk "git aws.push" only commited difference?
I am needing some help setting up a Yii2 Advanced Application on Heroku. I have already installed Yii locally using Composer, following their guide exactly: http://www.yiiframework.com/doc-2.0/guide-tutorial-advanced-app.html
My website works as it should locally, with frontend and backend:
http://localhost/yii2app/frontend/web/
http://localhost/yii2app/backend/web/
When I push it and run it on Heroku, I get errors complaining that some files are not found. What is weird, is with a bash terminal to my Heroku app, I can verify that the file is in fact there! Is Heroku not liking the '../../' to change directory?
PHP Fatal error: require(): Failed opening required '/app/frontend/web/../../common/config/main-local.php'
include_path='.:/app/.heroku/php/lib/php') in /app/frontend/web/index.php on line 12
In 'frontend/web/index.php' is Yii's stock code (line 12 is main-local.php):
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php')
);
If it had to do with the '../../' to change directory, then I would think the first require would have an error (for the main.php entry).
What am I missing to get Yii2 advanced running on Heroku?
UPDATE - I created a new Yii2 basic app. Should work and be simple, so I thought. Apparently even the basic app does not run on Heroku. There MUST be something left out from the docs, somewhere... Used composer to install Yii2 basic, put it under git, pushed it to a new heroku stack. Went to check out my app on heroku, adding /web/index.php to the end of the url.
ReflectionException
Class yii\debug\Module does not exist
I then put index.php in the root directory containing phpinfo(). I can confirm I get a phpinfo report. So php is running, it reports PHP 5.6.5.
Seems like Yii2 and Heroku do not play well without some magical (and un-documented) tricks. I have searched, and searched, and searched, and I can't find anything about this. I can't possibly be the only one trying to get a Yii app onto Heroku.
So I tried CloudControl. I deployed my stock Yii2 basic app to cloudcontrol, again I get a phpinfo report on the root index.php. Navigate to /web/index.php and get errors:
Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: /srv/www/code/vendor/bower/jquery/dist
What gives! I can run this locally just fine. When I push it to a cloud based host (Heroku or CloudControl) it fails! I figured the yiibasic app would be better to at least get it running for PoC, but Yii out of the box, will not run on either of those services. There is something not mentioned that I am missing.
Finally after hours and hours of messing around, I figured it out. Well, I still have one question left that I need to test (and try again). However, I managed to get both the yii basic and yii advanced apps running on Heroku. Still got errors on CloundControl though, but that's for another day.
I was missing 2 entries in my composer.json file. I dunno why these are not included in the Yii documentation if they are required in production. Here is my require block (I did not have to edit the require-dev section, just require):
"fxp/composer-asset-plugin": "*",
"ext-gd": "*"
The composer asset plugin was absolutely required. The GD extension is needed for the contact us page (I assume the captcha). I also commented out the first 2 lines in web/index.php for the YII_DEBUG defines. Once I did that, updated composer, updated git, and pushed, magic happened :)
I don't think they inform you that you need to edit web/index.php to remove them in the Yii2 docs. Seems they are only interested in getting you going for development. Yes the index file has comments, but we need to know to look there! If you don't remove them, Yii will load your debug tools, which don't exist. I assume when Heroku receives the push, it runs composer from the "require" block.
As for the Advanced template.. Frontend and Backend index.php files already have the debugging constants correct for dev and production. You just have to run php init --env=Production --overwrite=All on the server (I couldn't get heroku to do this, but another day). The Yii docs have you run init, then select development. This takes everything from the "environments/dev" folder and overwrite them in their locations in your app. This will fail when in development. So you have to switch it to production, which moves your production files into use. I understand why you would have these, so I get it.. Like I said, I tried heroku run bash, then running php init --env=Production --overwrite=All from the apps directory but it didn't seem to make the switch. So my app was missing the frontend/web/index.php file, and many more.
I was wondering how 'frontend/web/index.php' wasn't even in the directory, but further inspection I saw that many directories have gitignore files. So when you 'git push heroku master', 'frontend/web/index.php' along with the rest, never get pushed because they are ignored. So because I couldn't get Heroku to run Yii's init into production, my files just were not there.
Simple fix to get me running on Heroku with Yii Advanced (including adding the 2 mentioned packages to composer.json): I deleted all the gitignore files, ran init choosing production, updated git, and pushed to heroku. It runs :)
Now I need to figure out how to get init to do this for me so I don't have to delete the gitignore files.
As for this question, it is solved. Heroku can run Yii2 basic and advanced. The biggest issue I see is the Yii docs lacking the necessary composer packages to run in production. So I wonder if it's just Heroku needing those packages...
I have developed a Symfony2 app on my local machine. I access it using PHP's built-in server, via http://localhost:8000/
Question: how do I move this application to my VPS (LAMP CentOS) so that it can be accessed like this:
http://example.com
and is it any different for installing it on:
http://subdomain.example.com
PLEASE if by any chance you can provide a step by step instructions, it will be much appreciated and I'm sure useful to many others too. I'm used to working with stuff where you can simply move files from one place to another, update some config data and it works (Wordpress, coding without frameworks etc.)
The best solution to me is to have your project in a versionning system like git or svn without the vendors dir of course ...
This way, your simply have to do :
1) git clone your project into the prod dir
2) php composer.phar install to install your vendors
2b) create the mysql user with correct login and password according to your parameters.yml
3) php app/console doctrine:database:create to create your database with the credentials you set up in mysql
4) php app/console doctrine:schema:update --force to perform the database tables creation
5) testing the project :)
If you are not using a versionning system just upload your project to your server with an ftp software without the vendors directory ( it will be feeded by step 2) then perform 3rd , 4th and 5th steps !
For the subdomain part of your request you have to creats a subdomain folder on your server ( by using plesk if you have it ) or by manually creating a vhost config to specify the sub domain path. I can t provide you an example right now ( i m writing this from my mobile device and i don t have clear step by step procedure in order to achieve this )
[Install your environment]
So, First you need to install and run an apache Server. Find here the minimum basics to get your application running under Apache2. Then make sure you've PHP5 and MySQL up and running. Otherwise check,
Install and Configure MySQL Database Server
Installing and Configuring PHP
[Deploy your application]
Deploying can be a complex and varied task depending on your setup and
needs - Symfony.com
It's then up to you to choose the right way to deploy your application, you can do it,
Using Basic File Transfer
Using Source Control
Using Build scripts
I would recommend using Capifony which was build on top of Capistrano to adapt it to Symfony applications.
[Post-Deployment Tasks]
Your deployment process should be tailored to guarantee that all the required post-deployment tasks (Like updating your dependencies, setting your application configuration files, clearing the cache and dumping your assets, etc) are executed.
To get the big picture, read the How to deploy a Symfony2 application of the Cookbook.
I have developed a symfony application and it's done.
It's been a couple of days and I can't figure out how to deploy this into a real apache server, when I copy it to the public_html it doesn't work assets don't load properly.
Can some one give me a step by step description of how to deploy it so that when I navgiate to example.com url I see my symfony application.
Thank you
If you try to deploy your application on a server, you have to configure apache. The best way its to make a virtual host.
Here the documentation:
http://httpd.apache.org/docs/current/en/vhosts/examples.html
http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html
I would suggest using Capifony which provides a specialized set of tools on top of Capistrano, tailored specifically to symfony and Symfony2 projects. (according to the documentation)
The advantages of using capifony are,
deploying is as simple as running cap deploy from your project root directory.
It stores multiple releases.
It allows you to use SCM(s) to pull your application code down to the server.
You can configure it to run any batch command during the deployment.
It performs a transactional-like deployment process (if any step fails, the deployment is
rolled back and the current directory points to your last release)
You'll also need to troll through this part of the documentation to figure out how to get your application running under Apache.