I'm using a Node package called exec-php to execute PHP functions within Node.js app.
I would like to push that app to Heroku, but I'm wondering how to make that, and how that would be in the PHP bin locally.
I'm using /Applications/MAMP/bin/php/php7.0.0/bin/php. What would be the path to PHP bin in Heroku?
I tested vendor/bin/heroku-php-apache2 but it doesn't work, so what would be the path to PHP binary in Heroku?
You'll need to inform the build API that you'd like to use multiple buildpacks. Try:
$ heroku buildpacks:clear
$ heroku buildpacks:add heroku/php
$ heroku buildpacks:add heroku/nodejs
Then you can inspect the compiled slug via heroku run bash to verify that the bins are where you expect them to be.
The bin directory in heroku is : .heroku/php/bin/php
Related
I've been trying to get bitbucket pipeline deploy to Google cloud php app. But I keep getting a missing python executable error.Here's the script I have to install Google cloud SDK:
image: php:7.1.3
pipelines:
default:
- step:
caches:
- composer
script:
# Downloading the Google Cloud SDK
- curl -O -J https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-155.0.0-linux-x86_64.tar.gz
- tar -xvf google-cloud-sdk-155.0.0-linux-x86_64.tar.gz -C /tmp/
- /tmp/google-cloud-sdk/install.sh -q
- source /tmp/google-cloud-sdk/path.bash.inc
- gcloud -v
And get's stuck with this error:
To use the Google Cloud SDK, you must have Python installed and on your PATH. As an alternative, you may also set the CLOUDSDK_PYTHON environment variable
to the location of your Python executable.
Any help would be appreciated
You are using a PHP image (Docker image), which obviously does not include Python. Therefore, you either have to find another image which includes PHP and Python, or build one yourself. Building your own can be as simple as what is described in https://stackoverflow.com/a/45963743/4715679
this is my current status:
I have a running symfony environment, based on a docker image. Everything works fine and from PHPStorm i can execute phpunit tests. But i want to execute them manually from console.
After i started all services by using docker-compose up --build, i login into the phpfpm service by: docker-compose exec -it phpfpm bash
then i move into my symfony project folder that contain all folders and files like "app/, bin/, vendor/, ... composer.json... etc"
I could go by calling vendor/phpunit/phpunit/phpunit but i want to get a shorter way. Is there any chance, maybe calling bin/phpunit or something like this?
Thanks in advance,
Max
PHPUnit has that script in the own composer.json, so bin (or vendor/bin) directory should contains a relevant symlink after running composer install. Also check your composer.json for bin-dir settings.
At least you always can create a symlink:
$ ln -s vendor/phpunit/phpunit/phpunit phpunit
According to the symfony docs the preferable way of using phpunit is by .phar file. In this way you can download phpunit as a .phar file and it will works both outside and inside docker container.
wget https://phar.phpunit.de/phpunit-6.0.phar
php phpunit-6.0.phar --version
Type now php phpunit-6.0.phar to run tests.
I am trying to use Openshift for the first time to host a php site(PHP 5.4 cartridge) I am working on for a school project. I followed the directions here to push my existing repo to my gear, and can see that the code is on the gear by ssh-ing into the gear. What do I have to do now to host the website? I initially thought that I would just be able to see the index.php in my repo, but when I go to the provided url it is just a blank page. I think I may need to use the deploy action hook to cp the git repo somewhere, but not sure where. Any help would be appreciated.
With the PHP 5.4 cartridge the application root is the root of your application directory. Let me try and explain a bit further. If you create an application named "myphpapp" with the following command:
$> rhc app create myphpapp php-5.4
After the application is created, the git repository will be cloned to the directory you ran the create command. Change to that directory:
$> cd myphpapp
This is your application www root directory and is where you need to place files. For example, create a new test.php file like this:
$> echo "some php code" >> test.php
Add the file to your local git repository and then commit and push to your openshift server:
$> git add test.php
$> git commit -am "Adding a new file"
$> git push
When you run the git push command, the changes will be pushed to the remote git repository on the openshift server. Once the code is pushed, a hook on the server will see that a new file has been added to the repo and then deploy it to the www root on the openshift server. Once the deploy has finished, you can access the file by pointing to:
http://yourApp-yourDomain.rhcloud.com/test.php
Hope that helps.
--
gs
I did not read the documentation clearly enough. The root for the app is yourApp/php. So your repository has to have a php subdirectory inside of it, and that will be the app root. There is no need to copy your code from the repository to the root. As you have the correct structure, when you push your code the website will be live.
i'm trying to run a php script using the heroku scheduler. What command should i put in after the $ in heroku. I keep getting file not found. I have transferred the file i want to run to heroku but not luck with running it with the scheduler.
The default PHP buildpack on Heroku does not currently have PHP CLI support, so you can only use it to serve web requests via Apache and not for scripts in worker dynos. However, this is possible if you are using a PHP buildpack that does have CLI support.
To test it out, I forked the PHP buildpack, switched out the PHP binary with one that was compiled with CLI support, and put together small demo of running a scheduled PHP job on Heroku. See the project's readme for step-by-step instructions. To use this fork on an existing app, set the buildpack with:
$ heroku config:add BUILDPACK_URL=https://github.com/ryanbrainard/heroku-buildpack-php.git
Note, the release script in my fork sets up the PATH to resolve the php executable in /app/bin/php with just php, unlike the default buildpack that woud require using the absolute path.
How to run a PHP script with Heroku Scheduler?
Testing and setting up the job
With a directory structure and Procfile looking something like this:
├─ Procfile
├─ web/
├── (your webfiles)
├─ worker/
└── myscript.php
Procfile:
web: vendor/bin/heroku-php-apache2 web/
worker: php worker/myscript.php
Then you can test your worker from the command-line like so:
heroku run worker
To schedule a job, go into Heroku Scheduler and add the job in a similar fashion, but without the heroku run segment (else you'll get bash: heroku: command not found errors), just:
worker
Or, alternatively, directly:
php worker/myscript.php
Checking on the job
You can see the job in the app's logs. e.g.:
2017-09-01T14:19:37.397210+00:00 heroku[scheduler.9540]: Starting process with command `php worker/myscript.php`
Notes
The worker name in the Procfile could be set to something else. e.g.: myworker, mysuperduperscript, etc.
I included a web section, but it's optional if all you want is a worker / background service and don't need to serve files on the web.
Alternative: if, for whatever reason, you'd rather perform a GET/POST request on a URL, you can use the Temporize Scheduler add-on.
I am developing a PHP app on Heroku. Is it possible for me to use Foreman to test my application? Everywhere I look I find references to Ruby, but nothing for PHP.
Yes, using PHP 5.4 built-in web server:
sudo foreman start -f Procfile_dev
And in Procfile_dev:
web: php -S 127.0.0.1:80 -t /path/to/doc/root
This is how I develop locally. I also have a line worker: watchr watcher.rb that listens for file changes to combine/minify JS, compile SCSS, etc.
You could probably add db: /usr/bin/mysqld or similar to start mysql if need be.
ALSO: you'll want to install the Heroku Config add-on, which will write the app config keys to a .env file that Foreman will send to php server on startup (accessible via getenv just like on Heroku.)