I've just deployed php application into heroku with extension mongo db.
In previous (11/2014), it's ok.
But currently I received error messsage: The requested php extension ext-mongo * is missing from your system.
Here is the structure of project on github (using to deploy into heroku):
Root
php.ini
composer.json
composer.lock
Procfile
MySources
ext
mongo.so (this file is located inside ext folder).
php.ini:
extension_dir="/app/ext/"
extension=mongo.so
composer.json:
{
"require" : {
"silex/silex": "~1.1",
"monolog/monolog": "~1.7",
"ext-mongo": "*"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
Procfile:
web: vendor/bin/heroku-php-apache2
Any one can help me to configure or sugguest me to resolve this problem? Deploy with the lasted heroku and php 5.6.7.
You don't need the ext folder (because the extension is already available on Heroku), and you don't need the php.ini, which doesn't have any effect anyway, because you're not configuring Heroku to use it.
You need to run composer update so the ext-mongo requirement gets "frozen" to composer.lock.
If you don't have that extension installed locally on your system, then you should install it (along with a MongoDB server), because you really want to test your code locally before you blindly push it up to Heroku to see whether it works or not.
If, for any reason, you can't do that, a composer update --ignore-platform-reqs will prevent "The requested php extension ext-mongo * is missing from your system" to happen on your local machine, and generate the correct composer.lock even if the extension is missing.
This is, by the way, all clearly documented here: https://devcenter.heroku.com/articles/php-support#extensions
Related
I run Laravel 9 on Windows 10.
Everything worked find until installed this package:
https://spatie.be/docs/laravel-livewire-wizard/v1/introduction
and now I get this error in the browser when trying to browse my site:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.13. in C:\wamp64\www\highland9.local\vendor\composer\platform_check.php on line 24
After googling it I check all of these:
php version on Wamp shows 8.1.0
phpinfo() shows 8.1.0
localhost in the browser shows php version 8.1.0
Windows path points to: c:\wamp64\bin\php8.1.0
cmd php -v shows: 8.1.0
In my composer.json file:
it was:
"require": {
"php": "^8.0.2",
I changed it to:
"php":"^8.1.0"
and ran composer update
I tried removing the package like this:
composer remove vendor/spatie/laravel-livewire-wizard
It said there's nothing to remove.
I renamed the folder to laravel-livewire-wizardDEL
I removed the line:
"spatie/laravel-livewire-wizard": "^1.1",
from composer.json and ran composer update
Nothing helps, still get this error.
Can someone please help?
Check if you've overwritten the PHP version under the platform key in your project's local composer.json or the global ~/.composer/composer.json.
Look for the following section:
{
"platform": {
"php": "8.0.13"
}
See: Documentation - Config - platform
Use the following commands to dump the current value:
composer config platform
composer config --global platform
Using PuTTY (I don't have root access to the server) I typed composer require "paypal/rest-api-sdk-php:*" as it said here: https://github.com/paypal/PayPal-PHP-SDK/wiki/Installation-Composer and it works fine, but how can I install it into directory d/pp/ instead of root? I tried d/pp/composer require "paypal/rest-api-sdk-php:*" but that's not it
I already downloaded the SDK directly but it seems not to work properly so I want to try it this way and I want to learn it anyway
Create a file named composer.json in your root directory and add the following code to it:
{
"config": {
"vendor-dir": "d/pp"
},
"require": {
"paypal/rest-api-sdk-php": "*"
}
}
now run composer install.
The config parameter lets you define configurations for your packages.
The vendor-dir directive sets the package's destination.
If you want to add more packages - in your require:{} section just add those too and run composer update.
How do I install/enable PHP extension mbstring?
Heroku on its documentation says it's shared by default, and should be enabled once a Composer package require it. I tried adding it in composer.json file but nothing changed.
This is my project's composer.json:
{
"require": {
"fabpot/goutte": "^3.2",
"guzzlehttp/guzzle": "^6.2",
"paquettg/php-html-parser": "^1.7",
"ext-mbstring": "*"
}
}
After adding last dependency, I ran:
heroku run composer update
This is the error message I got:
The requested PHP extension ext-mbstring * is missing from your system. Install or enable PHP's mbstring extension.
Thank you
Heroku's filesystem is ephemeral. Any changes you make to it after your Dyno spins up can be lost at any time. This happens at least once per day, and possibly much more frequently.
Additionally, composer update is something that I would advise against running on a server. This command installs the newest available version of each library (or specific ones if you only update specific libraries) that fits what's in composer.json. If you ask for ~1.2 in composer.json you might get 1.2.1 on your development machine, but 1.2.9 in production. This can lead to some tricky bugs.
The composer install command installs the exact versions that are defined in your composer.lock file. It is much safer to run on a server, but it does mean that you've got to update your lock file locally and push it to your server.
For both of these reasons you should run composer update locally. This will update composer.lock, which should then be committed and pushed to Heroku. Heroku will run composer install, and you should be all set.
(Alternatively, you should also be able to run composer update 'ext-mbstring' to leave the rest of your dependencies alone. Be careful with composer update, and try to get in the habit of using composer install unless you know you need to update some of your dependencies.)
I have trouble installing devisephp for laravel. I am working on the latest version of homestead with php7. when i do composer update i get the following error.
Problem 1
- Installation request for devisephp/cms 1.4.* -> satisfiable by devisephp/cms[1.4.0].
- devisephp/cms 1.4.0 requires ext-imagick * -> the requested PHP extension imagick is missing from your system.
After having this message i installed imagick on my homestead environment added the extension to php.ini in cli and fpm and checked in homestead if imagick is working with a test file. Everything was working perfectly but on running composer update i still get the same error message from above. Does anyone have a clue what the problem can be.
The stange thing is that is kan git clone devisephp its bootstrap version completely working including image handling but when i add another package to laravel i again get the above message.
if you really can't install or don't want that extension to be validated you may skip it by supplying the
--ignore-platform-reqs
flag to your composer command
Please follow these steps
sudo apt-get install php-imagick
php -m | grep imagick // this should print 'imagick' it means installed correctly
sudo service apache2 restart //(if needed)
Try adding:
"ext-imagick": "*",
to your require block in your composer.json like so:
"license": "MIT",
"require": {
"ext-imagick": "*",
....
}
and run composer update
With the config.platform key in composer.js you can fake dependencies like php versions or extensions (you can't use an asterisk for the extension version, though!)
https://getcomposer.org/doc/06-config.md#platform
As a bonus, you can polyfill ext-imagick with this library: https://github.com/calcinai/php-imagick. it's not complete and relies on the command line ImageMagick. So far it works for me.
{
"require": {
"calcinai/php-imagick": "dev-master"
},
"config": {
"platform":{
"ext-imagick": "3.4.4"
}
}
}
I have installed composer.
My project dir tree looks something like this
/home/myproject/public_html/myproject.com
I initially installed it in:
/home/myproject/public_html/myproject.com/bin/composer/
But later moved it to:
/home/myproject/usr/local/bin/composer
Questions:
Where to I create composer.json ?
In the official docs they mention that in order to install new packages I need to write a require key in the json format in that file, does this mean that I dont have to upload the package through ftp?
The docs further say that I can simply install dependencies like ths:
php composer.phar install
I dont understand the workflow of this process (im fairly new).. what exactly do I need to do to get some packages going (like Respect)
Composer has 2 basic elements for you to consider:
The composer.php file itself - this can be located anywhere on your system - usually it is convenient to have it in you search path so you can invoke it by name (no path) from the command line.
Composer.json - this file is the configuration for your project. This is usually best located at the top level of your project. Ideally this is a directory outside the scope of your web server - so that it will never be exposed or served.
Symfony2 has some great documentation and examples of composer in use.
Also be aware that some packages you reference via composer will themselves have composer files - to ensure they match your required dependancies - and they may also have their own dependancies that need to be considered.
I would install composer.json in the following
/home/myproject/composer.json
It would be out of scope of the web server and could be used to manage many assets e.g.
public_html/
libs/
config/
docs/
vendor/
Where to I create composer.json ?
You should create composer.json to your project root like /home/myproject/public_html/myproject.com/composer.json. If all files of your application live inside your myproject.com folder.
In the official docs they mention that in order to install new
packages I need to write a require key in the json format in that
file, does this mean that I dont have to upload the package through
ftp?
Yes as long as you're not in shared hosting because most of them don't allow CLI (SSH).
The docs further say that I can simply install dependencies like this
php composer.phar install
Yes you can simple type the above command and composer.json will install the latest version of your package.
Composer.json (Respect Package)
{
"require": {
"respect/validation": "dev-master"
}
}
Now run composer install will install the require package.
For further packages
{
"require": {
"respect/validation": "dev-master",
"doctrine/orm": "2.*"
}
}
Now run update composer update it will download the doctrine/orm as well.