Can PHP applications hosted on Heroku be edited using Cloud9? - 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

Related

Pushing Laravel App to heroku fails - valid cache path error

I'm trying to push a test Laravel application to Heroku but whenever I try to do so I get an error and the deployment stops. This is whats displayed when I do a deploy:
remote: Generating optimized autoload files
remote: > Illuminate\Foundation\ComposerScripts::postInstall
remote: > php artisan optimize
remote:
remote:
remote: [InvalidArgumentException]
remote: Please provide a valid cache path.
remote:
remote:
remote: Script php artisan optimize handling the post-install-cmd event returned with error code 1
remote: ! Push rejected, failed to compile PHP app.
remote:
remote: ! Push failed
remote: Verifying deploy...
What's the issue here? The storage/framework folder has all the needed folders and they're included in the repository. So whats wrong here?
Just check the gitignore file if has /storage/.key or /storage/ remove it and again run commit and push.

Issue when pushing PHP/Laravel to Azure with Git

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.

OpenShift hot deploy needs an app restart

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

Heroku doesn't recognize my Laravel app as PHP app, and does not do composer install

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.

Openshift environment variables don't exist

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.

Categories