Enabling SSL for composer install - php

I know this question is all over the place on this site, but all the solutions haven't worked with me.
I get this error when running composer install:
In Factory.php line 650:
The openssl extension is required for SSL/TLS protection
but is not available. If you can not enable the openssl
extension, you can disable this error, at your own risk,
by setting the 'disable-tls' option to true.
I don't know where it's getting Factory.php from but it's not in my project directory.
I did all the proposed solutions. I renamed my PHP's php.ini-development file to php.ini, and uncommented the following:
extension=openssl
And since I'm on windows, this too:
extension_dir = "ext"
I have also enabled SSL through Laragon menu > Apache > SSL > Enable
My php.ini file is located in my laragon folder like this:
C:\laragon\bin\php\PHP7\php.ini
Then I noticed something: when I right-click on Laragon for the menu and go to php.ini, it says no php.ini file located (even though it's in the right spot.) As seen in the attached photo.
When all that didn't work, I saw another proposed solution that said to add the php.ini file to Apache's directory within Laragon as well, like this:
C:\laragon\bin\apache\httpd-2.4.54-win64-VS16\bin\php.ini
Note that I'm reloading Apache every time.
And I still get the error.
What could possibly be the problem? I don't want to disable-tls and I have no idea what the Factory.php file is.
Any help is appreciated. Thanks.

I think what you're missing in this case is a certificate for your PHP instance.
You can download this certificate file directly from: CURL's site
After that what you need to do is look for these entries in your php.ini file. Specifically [curl] and [openssl] which is right after [curl].
What you need to do is save the cacert.pem file in a location preferably in a directory in your web server's root directory or where you prefer and use the absolute directory for the configuration below.
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "absolute location of where you saved the cacert.pem file"
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile= "absolute location of where you saved the cacert.pem file"
Save the php.ini file, restart your server and try again. This should solve your issue.
UPDATE
If you check your PHP info phpinfo() you should have a section similar to this one:
If you don't you're probably not enabling openssl.

I've found the solution. To anyone else who needs it:
It's everything I did above, then as an initial step, what the other answer said which solves the "no file found" popup. But to solve the rest, I've figured out my problem was that before I did everything above in php.ini, I switched the php version Laragon was using (v8) to v7.4 (the one I've been trying to get to work.) This, for some reason, confuses Composer. So I had to uninstall composer itself from my computer and reinstall, but activate developer option by checking it in the installation wizard this time since I hadn't the first time around. After that, it worked.

Related

PHP 7.2.14 "short_open_tag = On" ignored

On a fresh install of Fedora 28 running PHP 7.2.14 I am experiencing a strange issue where short_open_tag = On in the main php.ini is being ignored. I have verified that there is only one instance of the flag in only the main php.ini (/etc/php.ini). I have tried setting the flag on in .htaccess with php_value short_open_tag 1. I have restarted Apache after each change. But when I verify with phpinfo() the flag is always set to Off. Has this flag been finally deprecated and the change is simply not reflected in the PHP change log (http://php.net/ChangeLog-7.php)? Looking through the PHP source (which I am no expert at) does not suggest an override so I am at a loss for explanation. Any insight would be appreciated.
I will first note that this question looks like a duplicate of this one. On the off chance it's not, here's my best answer.
The PHP documentation has a page on the opening tags which says:
PHP also allows for short open tag <? (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option).
Check phpinfo() and you may see a section entitled Configure Command which contains compilation options. See if there's an --enable-short-tags option in there anywhere. If not, listen to #phil and look for a section titled Additional .ini files parsed which may list other ini files that have been parsed.
If your search is as thorough as you suggest in your original post and you still cannot get short tags, it may be turned off in an apache configuration file or the short_open_tag directive may exist in more than one spot. A PHP.ini directive will override any prior values that might have been set.
A grep search might help. In my PHP info output, I see these values:
Loaded Configuration File - /etc/php5/apache2/php.ini
Scan this dir for additional .ini files - /etc/php5/apache2/conf.d
I can easily search all files in that location with this grep command:
grep -ir 'short_open_tag' /etc/php5/apache2
If you double/triple check all these ini files and restart apache and still can't get short_open_tag setting to work, this value may be set as an apache option. I suggest searching the apache configuration files for any reference to short_open_tag. The exact directory location may be different on your machine, but this grep command works for me
grep -ir 'short_open_tag' /etc/apache2
You should also keep in mind that your apache configuration may not be set up to even bother with .htaccess files so your attempt to override using .htaccess may be for naught unless you configure apache to actually use the .htaccess file. Assuming your apache configuration does bother parsing your htaccess file, this appears to be covered in another question here on SO.
And finally, if your server is configured to use PHP-FPM, then it uses a pool of PHP processes to handle PHP requests from the web server. If that's the case, you would need to restart php-fpm with this command:
sudo service php7.0-fpm restart
NOTE: this command may vary on different machines.

Editing php.ini is not causing any effect

I tried everything, but I can't make it work. I recently installed MAMP. The PRO version came with an option to add OAuth via a checkbox, but now that the PRO version expired I need to install it by hand.
When I check phpinfo() on my browser it says that the path to my php.ini file is:
/Applications/MAMP/bin/php/php7.1.0/conf/php.ini
Also, there is (none) under additional ini files. So I am pretty sure that is the correct php.ini file
The problem is that after adding the OAuth extension to the ini file, and restarting MAMP, PHP still can't find OAuth.
Also strange is that I don't see any of the other enabled extensions (like mcrypt) in the phpinfo() output.
Any tip in the right direction will be appreciated,
Thanks!
After much debugging, this is what I did in order to figure out the problem and solve it.
As suggested in the comments of my question, once I checked the http logs I found out that PHP was not finding the extensions.
I checked php.ini for extension_dir and it was pointing to a different path than the one that pecl was installing packages on.
If you need to find that path, simply use:
pear config-get php_dir
After correcting that everything works fine.

Installing PHP on Linux and php.ini file

I have installed PHP with Apache 2.2 on my Linux machine and all works fine following guide here
During the installation I had to copy the php.ini-development file into /usr/local/lib/php.ini, the question is why? Why exactly in this directory?
Default locations of the PHP configurations vary greatly by distribution. In any case, phpinfo() will allways tell you where is looks for your configurations.
So, create file with extension ".php" in your webroot and past this into it:
<?php
phpinfo();
Also, the default php.ini files contain plenty od usefull comments. Just read them and change what you need. Differences between dev and prod environments are usually only the verbosity. They show and log different ammounts of errors. Production usually shows no error at all.
(Debian and many other distributions put the PHP config into /etc/php5. This is actually the most reasonable place for configurations, but stick with what your distribution uses.)
The document you link to says this
You may edit your .ini file to set PHP options. [...]
If you instead choose php.ini-production, be certain to read the list of changes within, as they affect how PHP behaves.`
Have you tried something like
vi /usr/local/lib/php.ini
to see what's in it?
Maybe you need to read http://www.php.net/manual/en/configuration.file.php
You copied a default PHP.ini file, php.ini-development, to the standard 'php.ini' file in the location '/usr/local/lib/' the guide http://www.php.net/manual/it/install.unix.apache2.php
expected the php.ini file to be.
The php.ini file is a configuration file used by PHP when it is launched (runtime)

How to Open php.ini file from cPanel or WHM

Recently I have purchased a VPS and I have the root access. I need to enable the extension=php_mysqli.dll in php.ini. But I could not find the php.ini file. Actually I am a Windows User and I do not know how to use Linux or SSH Commands. I want to find php.ini file and open it manually and make my desired changes. Can Any one help me?
Edit, on a cPanel server you should not be editing the PHP.ini file to enable extensions like that.
Within WHM, locate EasyApache and go through the guided setup for Apache and PHP. In the 'Exhaustive Options' screen, you'll find a checkbox to enable the mysqli extension.
Enable all the extensions you need, then hit 'Save and Build'. This will rebuild Apache and PHP using the configuration you just selected.

Php.ini production vs development

I'm using XAMPP to develop on my localhost. I would like to remove the PHP notices and keep only the warnings. I know this is done through the php.ini file, however I'm having trouble locating it. I followed the path in phpinfo() and it led me to /xampp/php. Inside this folder are two php.ini files: one for production and one for development. I have set them both to the error reporting level I'd like, however I still receive notices which makes me believe that neither of these actually control error reporting. I'm using the latest version of XAMPP. So I guess my question is where is the true php.ini and what are these two other versions?
As of PHP 7 the regular php.ini file was removed and added with php.ini-production and php.ini-devlopment. In PHP's installation text file they state, "We advise you to use php.ini-production, because we optimized the default settings in this file for performance, and security."
So in short use the php.ini-production
First, make sure you're editing php.ini, not php-development.ini or php-production.ini or anything BUT php.ini. After that, ensure you restart your Apache server or your changes won't take effect.
Also, check out ini_set for setting ini values at runtime.
I had this confusion, in my computer, the php.ini file didn't appear with the .ini extension name visible - it was just php , and in the type column, it has the value 'configuration settings'
I downloaded php-8.1.0 from official website. php.ini or configuration settings file is not present in it. Instead it has been replaced by two files i.e. php.ini-development and php.ini-production.
My requirement was to edit the php.ini file in order to enable pgsql extension. Alas! there were not one but two .ini files. Being new to php, I made changes to both the files but it didn't worked.
After doing some research, I came to know that in the recent versions of php (not sure from which), user is provided with two .ini files. As name suggests, php.ini-development contains settings suitable for development environment and php.ini-production contains settings suitable for production environment. As per your requirement, you need take backup of anyone of the file and rename that file to php.ini. In this file you will need make required changes for your php environment.
If you compare the two files using tools such as diff-merge, you will get more in-depth understanding.
php.ini.development and php.ini.production are entirely different from php.ini.
the problem is that in the php folder the required php.ini is not marked along with its extension ( .php). Only php is written.Check the properties of the file 'php' of "*configuration settings*" type.it must be .ini,This is the exact file which manages error reporting.
In XAMPP version 1.8.1 php.ini file located at \xampp\php\php.ini modify line 922 upload_max_filesize = 2M
Note: 2M means 2MB, so change to 10M for 10MB file upload. Also note that php.ini-development and php.ini-production are different files from php.ini.
My issue is that I was editing the php.ini-production and overlooked the standard php.ini file.
I edited the php.ini file by adding extension=php_odbc.dll and it fixed the error.
PHP 5.3.0 has significantly improved performance and parsing of INI files, and adds several new syntax features.
The standard php.ini files have been re-organized and renamed. php.ini-development contains settings recommended for use in development environments. php.ini-production contains settings recommended for use in production environments
The PHP.ini file is still there, only it doesn't include the extension .ini, the extension has been removed. You will notice two file name php, one is application file another is configuration setting when you open configuration setting in notepad you will notice that it has ini extension. so the php configuration file is ini file.

Categories