I set up my scaled PHP app to deploy by git push. Everything looks good, as far as I can see, but after the deployment is finished, the changes take no effect. I have to restart the app.
remote: Not stopping cartridge php because hot deploy is enabled
remote: Syncing git content to other proxy gears
remote: Building git ref 'beta', commit 1234567
remote: Preparing build for deployment
remote: Deployment id is 1234567
remote: Activating deployment
remote: Not starting cartridge haproxy because hot deploy is enabled
remote: Not starting cartridge php because hot deploy is enabled
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
Any ideas?
To answer my own question - this was a bug in Openshift Online:
https://bugzilla.redhat.com/show_bug.cgi?id=1225327
Related
This is very confusing to me. I have built a simple heroku app. It works fine locally. It actually works fine on Heroku IF I push the vendor directory, but then heroku warns me that I should not push the composer vendor directory. The message directs me to a link that instructs me to use composer.lock file for dependencies. So I added a .gitignore to ignore the vendor directory and pushed again, but when I did that, the app doesn't work. I checked the file structure on the heroku remote and it appears dependencies were installed correctly, but the app doesn't work. I'm trying to do this the right way, so I really want this to work, even though I know I can just push my vendor folder and it will work. Has anyone encountered this?
Here is the code from my composer.json file
{
"require": {
"salesforce-mc/fuel-sdk-php": "1.2.2",
"guzzlehttp/guzzle": "~6.0",
"ext-soap": "*",
"php": "7.1.28",
"ext-mcrypt": "*"
}
}
and my Procfile
web: vendor/bin/heroku-php-apache2
The error I get when I try to load the page is pretty generic
This page isn’t working project.herokuapp.com is currently unable to handle this request.
HTTP ERROR 500
Here are the heroku logs
$ heroku logs
2019-04-26T18:14:40.303998+00:00 app[api]: Initial release by user stan_alach#hotmail.com
2019-04-26T18:14:40.888724+00:00 app[api]: Enable Logplex by user stan_alach#hotmail.com
2019-04-26T18:14:40.888724+00:00 app[api]: Release v2 created by user stan_alach#hotmail.com
2019-04-26T18:14:40.303998+00:00 app[api]: Release v1 created by user stan_alach#hotmail.com
2019-04-26T18:15:12.000000+00:00 app[api]: Build started by user stan_alach#hotmail.com
2019-04-26T18:15:21.000000+00:00 app[api]: Build succeeded
2019-04-26T18:15:22.259480+00:00 heroku[web.1]: Starting process with command `vendor/bin/heroku-php-apache2`
2019-04-26T18:15:20.868799+00:00 app[api]: Deploy 1f57bbb2 by user stan_alach#hotmail.com
2019-04-26T18:15:20.868799+00:00 app[api]: Release v3 created by user stan_alach#hotmail.com
2019-04-26T18:15:20.887739+00:00 app[api]: Scaled to web#1:Free by user stan_alach#hotmail.com
2019-04-26T18:15:24.264059+00:00 app[web.1]: Optimizing defaults for 1X dyno...
2019-04-26T18:15:24.284000+00:00 app[web.1]: 4 processes at 128MB memory limit.
2019-04-26T18:15:24.288460+00:00 app[web.1]: Starting php-fpm...
2019-04-26T18:15:26.290267+00:00 app[web.1]: Starting httpd...
2019-04-26T18:15:26.665144+00:00 heroku[web.1]: State changed from starting to up
2019-04-26T18:15:34.496861+00:00 heroku[router]: at=info method=GET path="/" host=cloud-buddy.herokuapp.com request_id=7fa87fe1-fb53-4ef6-ae75-f14488321528 fwd="174.65.133.198" dyno=web.1 connect=0ms service=645ms status=500 bytes=169 protocol=http
2019-04-26T18:15:34.495116+00:00 app[web.1]: [26-Apr-2019 18:15:34 UTC] PHP Fatal error: Uncaught Error: Class 'FuelSdk\SQZL_ET_Client' not found in /app/index.php:18
2019-04-26T18:15:34.495133+00:00 app[web.1]: Stack trace:
2019-04-26T18:15:34.495135+00:00 app[web.1]: #0 {main}
2019-04-26T18:15:34.495201+00:00 app[web.1]: thrown in /app/index.php on line 18
2019-04-26T18:15:34.496655+00:00 app[web.1]: 10.51.197.106 - - [26/Apr/2019:18:15:33 +0000] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36
2019-04-26T18:16:07.874786+00:00 app[api]: Starting process with command `bash` by user stan_alach#hotmail.com
2019-04-26T18:16:10.152678+00:00 heroku[run.9911]: State changed from starting to up
2019-04-26T18:16:10.244363+00:00 heroku[run.9911]: Awaiting client
2019-04-26T18:16:10.279025+00:00 heroku[run.9911]: Starting process with command `bash`
2019-04-26T18:20:32.049330+00:00 heroku[run.9911]: State changed from up to complete
2019-04-26T18:20:32.028902+00:00 heroku[run.9911]: Process exited with status 0
Here is the output I get when I include the vendor folder, and when I do this, the app actually works. I guess for now I'll just let it be, since it's working, but it would be nice to know how to do it the proper way. There must be some sort of file structure issue with the autoload that is not resolving itself when heroku installs the dependencies.
$ git push heroku master
Enumerating objects: 612, done.
Counting objects: 100% (612/612), done.
Delta compression using up to 8 threads
Compressing objects: 100% (595/595), done.
Writing objects: 100% (612/612), 1.08 MiB | 307.00 KiB/s, done.
Total 612 (delta 247), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote: - php (7.1.28)
remote: - ext-mcrypt (bundled with php)
remote: - ext-soap (bundled with php)
remote: - apache (2.4.39)
remote: - nginx (1.14.2)
remote:
remote: ! WARNING: Your app's PHP version is no longer actively maintained
remote: !
remote: ! Only security updates will be provided for your PHP version
remote: ! series by the PHP Group until its end-of-life on 2019-12-01.
remote: !
remote: ! It is strongly recommended you update your app to a version of
remote: ! PHP with "active support" status immediately to ensure you get
remote: ! the latest bugfixes and security updates each time you deploy.
remote: !
remote: ! You may check the list of versions supported by the PHP Group
remote: ! and their EOL dates here: http://php.net/supported-versions.php
remote: !
remote: ! For a list of supported runtimes & extensions on Heroku, please
remote: ! refer to: https://devcenter.heroku.com/articles/php-support
remote:
remote: -----> Installing dependencies...
remote: Composer version 1.8.4 2019-02-11 10:52:10
remote:
remote: ! WARNING: Composer vendor dir found in project!
remote: !
remote: ! Your Git repository contains Composer's 'vendor' directory.
remote: !
remote: ! This directory should not be under version control; only your
remote: ! 'composer.json' and 'composer.lock' files need to be added, as
remote: ! Composer will handle installation of dependencies on deploy.
remote: !
remote: ! To suppress this notice, first remove the folder from the index
remote: ! by running 'git rm -r --cached vendor/'.
remote: ! Next, edit your project's '.gitignore' file and add the folder
remote: ! '/vendor/' to the list, then commit the changes.
remote: !
remote: ! For more info, refer to the Composer FAQ:
remote:
remote: Loading composer repositories with package information
remote: Installing dependencies from lock file
remote: Nothing to install or update
remote: Generating optimized autoload files
remote: -----> Preparing runtime environment...
remote: -----> Checking for additional extensions to install...
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 16.2M
remote: -----> Launching...
remote: Released v3
remote: https://cloud-buddy.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/cloud-buddy.git
* [new branch] master -> master
Turns out, this had more to do with file structure. My index.php was at the root of my application. When I actually viewed file structure on Heroku I realized that Heroku was expecting something different. So basically the autoload wasn't working properly because of the directory structure. I restructured to put my html files in a /public directory and left my vendor folder at the root. Now it works flawlessly and I don't need to upload the vendor directory. My file structure now looks like this:
.git
public
--index.php
src
vendor
--autoload.php
composer.json
composer.lock
Procfile
and my Procfile just has this one line:
web: vendor/bin/heroku-php-apache2 public/
And finally, just make sure that in your php files within the /public directory go one level up to get to php files in the root and subfolders. So that line looks like:
require '../vendor/autoload.php';
If I push my PHP app from Cloud9 to Heroku, my application will be deployed on Heroku. The question is that in the future, if I have to perform some bug fixing or update etc., will I be able to edit the application hosted/deployed on Heroku?
EDIT:
zeldish:~/workspace/appzeld (master) $ git push heroku master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 381 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Using set buildpack heroku/php
remote: -----> PHP app detected
remote:
remote: ! WARNING: No 'composer.json' found.
remote: Using 'index.php' to declare app type as PHP is considered legacy
remote: functionality and may lead to unexpected behavior.
remote:
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote: NOTICE: No runtime required in composer.lock; using PHP ^5.5.17
remote: - apache (2.4.20)
remote: - nginx (1.8.1)
remote: - php (5.6.22)
remote: -----> Installing dependencies...
remote: Composer version 1.1.2 2016-05-31 19:48:11
remote: -----> Preparing runtime environment...
remote: NOTICE: No Procfile, using 'web: vendor/bin/heroku-php-apache2'.
remote: -----> Checking for additional extensions to install...
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 13.9M
remote: -----> Launching...
remote: Released v4
remote: https://*******.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/********.git
59f63a5..4375225 master -> master
Simple answer is yes. You will be able to push every changes you make to your application. in order to do that you can simply run below command and you will be able to see all the changes you have made after you push to your repository.
$ git init
$ heroku create
$ echo '{}' > composer.json
$ heroku buildpacks:set heroku/php
(you will need to run above commands when you deploying your app first time. This command will create repository on heroku for you and it will set php buildpack on heroku.)
$ git add .
$ git commit -am "some comment"
$ git push heroku master
$ heroku open
to getting started click here
I am developing a PHP-Laravel Web App in Microsoft Azure Cloud. I set up a Local Git in the cloud for version control. I am also using PHP Storm by JetBrains as the IDE.
Each time I push files from my computer to azure, git performs some operations which delay my deployment. Even if I change a single file it will take around a minute to finish. I am new to Laravel and Composer so I was wondering if it is a normal thing to do or is it my mistake?
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.35 KiB | 0 bytes/s, done.
Total 7 (delta 6), reused 0 (delta 0)
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '0f7a0fa743'.
remote: Running custom deployment command...
remote: Running deployment command...
remote: Install Dependencies with Composer
remote: Loading composer repositories with package information
remote: Installing dependencies from lock file
remote: Nothing to install or update
remote: Generating optimized autoload files
remote: ...........................
remote: > Illuminate\Foundation\ComposerScripts::postInstall
remote: > php artisan optimize
remote: ..
remote: Generating optimized class loader
remote: ..............................
remote: Handling Basic Web Site deployment.
remote: ...
remote: KuduSync.NET from: 'D:\home\repository' to: 'D:\home\site'
remote: Copying file: '.idea\workspace.xml'
remote: Copying file: 'app\Http\routes.php'
remote: Copying file: 'vendor\autoload.php'
remote: Copying file: 'vendor\composer\autoload_classmap.php'
remote: Copying file: 'vendor\composer\autoload_files.php'
remote: Copying file: 'vendor\composer\autoload_namespaces.php'
remote: Copying file: 'vendor\composer\autoload_psr4.php'
remote: Copying file: 'vendor\composer\autoload_real.php'
remote: Copying file: 'vendor\composer\autoload_static.php'
remote: Copying file: 'vendor\composer\ClassLoader.php'
remote: Copying file: 'vendor\composer\installed.json'
remote: Copying file: 'vendor\composer\LICENSE'
remote: Finished successfully.
remote: Running post deployment command(s)...
remote: Deployment successful.
When you deploy your PHP application to Azure App Services via Git. The deployment task not only upload and copy the code scripts on the root directory on Azure, but also will run composer commands if you have composer.json configuration file on your root directory and enabled the composer extension on Azure App Services.
It will run composer install, which will install the dependencies and run the custom commands set in scripts section.
So it will take time.
Azure App Services as a PaaS for hosting production applications, you can push your code to Azure after you have finished a stage of developing work.
Meanwhile, you can try the suggestion provided by #Achraf Khouadja, leverage the GitHub repository as a middle layer. with which, you can only upload your codes to GitHub, and Azure fabric will sync the code and run the deployment task automatically.
You will not need to wait the response in your IDE, it will save your time.
I'm trying to publish my Laravel app on Heroku.
I have excluded the composer.lock file from .gitignore, and created a Procfile containing
web: vendor/bin/heroku-php-apache2 public
I created my app with
heroku create myapp;
git push heroku master;
Then I get the following output:
git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags heroku master:master
Pushing to https://git.heroku.com/myapp.git
POST git-receive-pack (1914 bytes)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote: -----> Resetting git environment
remote:
remote: PRO TIP: Specify a node version in package.json
remote: See https://devcenter.heroku.com/articles/nodejs-support
remote:
remote: -----> Defaulting to latest stable node: 0.10.35
remote: -----> Downloading and installing node
remote: -----> Exporting config vars to environment
remote: -----> Installing dependencies
remote: npm WARN package.json myapp#0.0.0 No repository field.
remote: -----> Cleaning up node-gyp and npm artifacts
remote: -----> Building runtime environment
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing... done, 9.6MB
remote: -----> Launching... done, v5
remote: https://myapp.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/myapp.git
5b1c663..0dff021 master -> master
updating local tracking ref 'refs/remotes/heroku/master'
Completed successfully
If I browse to my app, however I get an application error.
When I look to my logs, it says
app[web.1]: bash: vendor/bin/heroku-php-apache2: No such file or directory
I suspect that somehow, Heroku didn't do composer install, as it's not in my git output, and maybe it didn't even recognize that my app is an PHP app?
To be sure, I also included an empty index.php file in my root. Didn't help.
What am I missing here?
I believe I found it. Should better read the lines ("Node.js app detected").
Solved by firing this command :
heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
and pushing again
Haha, just simply drop the package.json in your laravel project.
And then Heroku will detect your app as a php project.
Be sure to include the trailing slash on public: public/. This was my issue - I am using Laravel and got a Image source not readable and NotReadableException in AbstractDecoder.php line 302: because it thought at AbstractDecoder->init('/app/public') in AbstractDriver.php line 64 was a file, not a folder.
I've added a MySQL cartridge to a install and can see the environment variables when running php through the CLI interface..
php -r 'echo $_SERVER["OPENSHIFT_MYSQL_DB_HOST"];'
// 127.2.234.2
However when calling the same variable through the web interface the variable is not set. I've restarted both apache and the entire app through rhc app restart
Related:
https://stackoverflow.com/questions/24434922/apache-on-openshift-undefine-environment-variables
You have been told not to hard code the IP Address as it will change.
eg https://developers.openshift.com/en/managing-environment-variables.html
But when you run your script on your website the IP Address is missing.
<?php
print(getenv('PHPRC'));
print('<p>');
print(getenv('OPENSHIFT_MYSQL_DB_HOST'));
?>
You get this. The IP Address is Missing.
/var/lib/openshift/xxf1b5b94382ec898b00xxxx/php/configuration/etc/php.ini
Instead of
/var/lib/openshift/xxf1b5b94382ec898b00xxxx/php/configuration/etc/php.ini
127.5.nnn.nnn
This may be because you have not used Git to push files onto your server.
You may have been like me (a luddite?) and preferred sftp for my simple website.
Steps needed - if you are not familiar with git
Look on your OpenShift website, the Applications tab, Source Code
ssh://xxf1b5b94382ec898b00xxxx#xxxx-xxxxx.rhcloud.com/~/git/php.git/
This assumes you have git installed locally.
This takes a copy of your OpenShift git repository off the server and puts it on your local machine.
git clone ssh://xxf1b5b94382ec898b00xxxx#pappname.rhcloud.com/~/git/php.git/
Cloning into 'php'...
remote: Counting objects: 19, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 19 (delta 2), reused 19 (delta 2)
Receiving objects: 100% (19/19), 18.17 KiB | 0 bytes/s, done.
Resolving deltas: 100% (2/2), done.
Checking connectivity... done.
copy a few files into php subfolder it has created on your local machine
$ git add .
$ git commit -m "A change to my application"]
$ git push
This will restart your application and mysql.
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 2.80 KiB | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Stopping PHP 5.4 cartridge (Apache+mod_php)
remote: Waiting for stop to finish
remote: Waiting for stop to finish
remote: Stopping MySQL 5.5 cartridge
remote: Stopping PHPMyAdmin cartridge
remote: Waiting for stop to finish
remote: Waiting for stop to finish
remote: Building git ref 'master', commit 092cd25
remote: Checking .openshift/pear.txt for PEAR dependency...
remote: Preparing build for deployment
remote: Deployment id is e7791836
remote: Activating deployment
remote: Starting MySQL 5.5 cartridge
remote: Starting PHPMyAdmin cartridge
remote: Starting PHP 5.4 cartridge (Apache+mod_php)
remote: Application directory "/" selected as DocumentRoot
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
Now your environment variable will work correctly.
Yes, sftp is probably quicker.