Change php location of composer - php

How can I change the location of PHP used by composer?
I tried run the setup again, but it keep using the old one.
The PHP exe file you specified did not run correctly:
D:\servers\php_5_5_37_x86\php.exe
The php.ini used by your command-line PHP is: D:\servers\php_5_5_37_x86\php.ini
A setting in your php.ini could be causing the problem: Either the 'extension_dir' value is incorrect or the dll does not exist.
Program Output:
Warning: PHP Startup: Unable to load dynamic library 'D:/Servers/php_5_4_39_x86/ext/php_curl.dll' - Não foi possível encontrar o módulo especificado.
in Unknown on line 0

You need to edit the path to your 'php folder' in 'PATH' variable on the system environment variables.
check this :
https://superuser.com/questions/949560/how-do-i-set-system-environment-variables-in-windows-10

Related

CURL is enabled in PHP but disabled in Laravel

I want to use CURL in my Laravel 5.3 app but it returns error :
Call to undefined function App\Http\Controllers\curl_init()
I created info.php file to test curl contains :
<?php
var_dump(function_exists('curl_version'));
phpinfo();
?>
it returns true and shows that curl is enabled :
but when I test it inside laravel :
dd(function_exists('curl_version'));
it returns false !!
When I run php --ini in terminal it returns :
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_curl.dll' - /usr/lib/php/20151012/php_curl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
I tried to use curl_init() in info.php outside laravel and it works!
Why does this happen and how to fix it ?
In your error message PHP tries to resolve the curl_init function within the App\Http\Controllers namespace. If the underlying issue is not related to the PHP Warning you later pasted, the curl functions should work if you prefix them with backslash, like \curl_init.
This way you're telling PHP that the function resides within the top level namespace, not within App\Http\Controllers
I was running Laravel with:
php artisan serve --host 0.0.0.0
but when I changed it to :
php artisan serve --host my_private_IP
it's working now.

App Engine PHP - cant find curl.so

Run dev_appserver.py and now get an error relating to curl.so:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\dev\google-cloud-sdk\platform\google_appengine\php\php-5.5-Win32-VC11-x86\curl.so' - The specified module could not be found.
This file does appear to be missing from the directory specified but haven't touched anything and have not had this error before.
How do I resolve?
Additional info
I have found there is already a php.ini file in same directory as app.yaml, just a few basic lines:
extension = "curl.so"
;extension=C:\dev\xampp\php\ext\php_curl.dll
;extension=C:\dev\xampp\php\ext\php_mysqli.dll
So I changed it to comment out the first line and restore the second line:
;extension = "curl.so"
extension=C:\dev\xampp\php\ext\php_curl.dll
;extension=C:\dev\xampp\php\ext\php_mysqli.dll
The error now changes to cant find ...php_curl.dll.
Yet the file seems to be there:
So why the error now? seems the path to dll is correct.
If you want to use Curl and not Curl Lite, then you need to reference the .dll version while using a Windows based system. Create a php.ini file in the same directory as your app.yaml file add the following line to it:
extension = php_curl.dll
If instead you want to use curl lite, you can remove the line above and instead add:
google_app_engine.enable_curl_lite = "1"
to the php.ini file.

Php in cmd unable to load ALL dinamic libraries

When i use php in cmd Windows console i got the following error:
C:\wamp64\bin\php\php5.6.25>php
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.6.25/ext/php_bz2.dll' - No se puede encontrar el m¾dulo especificado.
in Unknown on line 0
[...]
And continues whit ALL the dll libraries. I Chek the rute and its ok. And when my wamp start a page whit php i dont get this error
For example i got the error when i type:
cd C:\wamp64\www\ServicioApp\scripts
php script_notificaciones.php
I run php --ini and search in the file, and i got:
extension_dir ="c:/wamp/bin/php/php5.6.25/ext/"
My guess is that WAMP (its Apache config) looks for php.ini in different location than command line invoked script - run php --ini in console to find it. You will need to check and fix (or disable) extension paths there.
Search for line with extension_dir - it should point to ext folder with extensions (dlls). You may need to switch to backslashes there:
extension_dir = "c:\wamp\bin\php\php5.6.25\ext"
I found the problem my rute was:
c:/wamp/bin/php/php5.6.25/ext/
And must be:
c:/wamp64/bin/php/php5.6.25/ext/
I miss the 64*

cURL 7.27.0-1 fails to load via Apache PHP, but works great on php command line

We have an intranet site that has multiple PHP scripts which start using curl_init(). The other day there was an update for ArchLinux which messed with some of the dependencies of cURL (glibc). This caused the curl module to not properly load in PHP, that is, extension_loaded('curl') fails.
I get this error from Apache /var/http/error_log:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/modules/curl.so' - /lib/libc.so.6: version `GLIBC_2.16'
not found (required by /usr/lib/libcurl.so.4) in Unknown on line 0
The weird thing is we have another nearly identical script (on the same machine) that runs on PHP command line using curl_init() that runs via a cron job and PHP loads cURL properly during the execution of this script. That works perfectly fine.
cURL is configured to run in php.ini via extension=curl.so
If I check phpinfo(), I see '--with-curl=shared'. However it does not show the cURL info table. This tells me that the module isn't loading properly.
The curl.so file is in place at: /usr/lib/php/modules/curl.so
These cURL scripts also normally function properly, they are currently working great on another test machine.
This issue occurs on PHP 5.4.5
ldd /usr/lib/libcurl.so.4
linux-gate.so.1 (0xb7770000)
libssh2.so.1 => /lib/libssh2.so.1 (0xb76de000)
librt.so.1 => /lib/librt.so.1 (0xb76d5000)
libssl.so.1.0.0 => /lib/libssl.so.1.0.0 (0xb7673000)
libcrypto.so.1.0.0 => /lib/libcrypto.so.1.0.0 (0xb74ad000)
libz.so.1 => /lib/libz.so.1 (0xb7495000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb747a000)
libc.so.6 => /lib/libc.so.6 (0xb72d4000)
libdl.so.2 => /lib/libdl.so.2 (0xb72cf000)
/lib/ld-linux.so.2 (0xb7771000)
In my distro, the change they made was that /lib is now a symlink to /usr/lib: http://www.archlinux.org/news/the-lib-directory-becomes-a-symlink/
EDIT
I tried what DaveRandom suggested here...
[root http]# php -r " echo (file_exists('/usr/lib/php/modules/curl.so')) ? 'It exists.' : 'It doesn\'t e.'; "
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/json.so' - /usr/lib/php/modules/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: file_exists(): open_basedir restriction in effect. File(/usr/lib/php/modules/curl.so) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in Command line code on line 1
Warning: file_exists(): open_basedir restriction in effect. File(/usr/lib/php/modules/curl.so) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in Command line code on line 1
It doesn't exist.
It failed because it didn't allow access to that path via the ini, so I reconfigured it and tried again...
[root http]# php -r " echo (file_exists('/usr/lib/php/modules/curl.so')) ? 'It exists.' : 'It doesn\'t exist.'; "
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/json.so' - /usr/lib/php/modules/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
It exists.
Freaky thing though is that JSON is actually working...
[root m]# php -r " echo (extension_loaded('json')) ? 'It is loaded' : 'It is not loaded'; "
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/json.so' - /usr/lib/php/modules/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
It is loaded
I guess the question is, what would cause cURL to work on command line, the module file to be there, but fail to load the extension via Apache PHP.
Then on the other hand what would cause JSON to give a warning, but still actually load?
Anybody know what the heck this could be?
Thanks
Alrighty, I found a work around. It's basically just to downgrade from cURL 7.27.0-1 to 7.26.0-1, which kind of sux, but it works:
I think this issue was unique to ArchLinux, but this will fix it (if you're an ArchLinux user like me).
mkdir /tmp/pacman_build
cd /tmp/pacman_build
cp /var/cache/pacman/pkg/curl-7.26.0-1-`uname -m`.pkg.tar.xz .
tar -xJf curl-7.26.0-1-`uname -m`.pkg.tar.xz
LD_PRELOAD=/tmp/pacman_build/usr/lib/libcurl.so pacman -U /var/cache/pacman/pkg/curl-7.26.0-1-`uname -m`.pkg.tar.xz
Please note, this requires you to recently have version 7.26.0-1 of curl in your package manager cache. If this fails, check /var/cache/pacman/pkg for another version of curl. If you don't have one in there, you'll have to find one.

PHP Extension (memcache|memcached) not showing in phpinfo() but showing in php -m and php -i?

I am getting both modules listed as installed / configured when I use:
php -m
or if I use:
php -i
but when I use:
$m = new Memcache;
// or
$m = new Memcache();
// or
$m = new Memcached();
//or
$m = new Memcached;
I get the following error:
Fatal error: Class 'Memcached' not found
I am running on a Mac - OS X (10.5.7) with default install of apache & php. Additionally, I have memcached running as a daemon on 127.0.0.1:11211 and libmemcache as required by the php-memcached library. I have restarted apache tons of times and even done a machine restart.
Does anyone know why the modules/extensions show up in the command line but not in my phpinfo()? I am literally stumped, after 3 hours of googling, I am just about ready to give up.
Also, please note, my phpinfo() outputs my ini files as follows AND they are both the exact same file:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /private/etc/php.ini
UPDATE:
Apache is failing to load the extension.
[Fri May 14 04:22:26 2010] [warn]
Init: Session Cache is not configured
[hint: SSLSessionCache] PHP Warning:
PHP Startup: Unable to load dynamic
library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so'
- (null) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load
dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
- (null) in Unknown on line 0
Does anyone know why or how this would happen? Both of the files referenced above DEFINITELY ARE there. Should I move this question to server fault?
Your webserver is probably using mod_php, which is a seperate bit of code from the standalone (CLI) interpreter. If they are both using the same ini file, and the memcache extension is configured in the ini file, then it sounds like for some reason, the mod_php is failing to load the extension - check your webserver error_log for startup errors.
It may be that the mod_php was compiled without memcache support (most extensions need to have a stub file linked into the php code, even though the bulk of the code is not linked until run time). Or it may be a permissions problem on the shared object file. Or your webserver may be running chroot, and unable to find the extension (which would also mean that although the ini files appear to have the same path, this is relative to different roots).
HTH
C.
because both versions use different php.ini
place your php.ini into location noted in the phpinfo() outout
I would suspect that the issue revolves around permissions. When you run php from comand line, it runs as the user invoking it. When run as an apache module, it runs as "nobody".
I would assume that the memcached.so file, or the directory it's in does not have proper permissions.
I stumpled upon this post and was having the exact same problem with an extension in my php -i but not in phpinfo(). Mine was a permissions problem because of selinux on a CentOS machine. I had to change ownership and permissions and now it is working as expected.
Set php path in environment variables as given below.
Right-click on "My Computer"
Properties
Advanced Tab > Environment Variables
Under System variables, scroll down to find "Path", select and click on Edit.
Add path to your php install on the end (make sure to precede with semi-colon ";"). Example: ";C:\php7"
Click Ok.

Categories