Laravel, enable MCrypt for CLI - laravel

I know the question was asked a lot, but most answers were for linux/xOS systems and no thread about windows,
Lately I'm trying to learn laravel which need mcrypt extension enabled which was easy with wampmanager and it worked fine, but the CLI using php artisan doesn't work and only dd Laravel requires the Mcrypt PHP extension.
I only have one version of php and accessing the php.ini.
I only find
[mcrypt]
; For more information about mcrypt settings see http://php.net/mcrypt-module-open
; Directory where to load mcrypt algorithms
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
mcrypt.algorithms_dir=
; Directory where to load mcrypt modes
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
mcrypt.modes_dir=
I've tried configuring it by downloading libmcrypt and setting it in php\ext with no avail.

Run php --ini to find out which config files are loaded.
CLI could use another config-file than php.ini.
EDIT:
Make sure the file got these things correct:
extension_dir This should point to your extension-directory. There may be a line there which you could just uncomment. Otherwise it's probably "ext/" or something like that.
Also, make sure
extension=php_mcrypt.dll is uncommented.
You can use php -info to check what extensions are available.

Related

how to solve "you are running Composer with SSL/TLS protection disabled"? in Laravel [duplicate]

composer create-project flarum/flarum . --stability=beta
I try to run this command, but it gave me this error.
[RuntimeException]
The openssl extension is required for SSL/TLS protection but is not availab
le. 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 tried to add "extension=php_openssl.dll" to "php.ini", but it still got this error
The same error occurred to me. I fixed it by turning off TLS for Composer, it's not safe but I assumed the risk on my develop machine.
try this:
composer config -g -- disable-tls true
and re-run your Composer. It works to me!
But it's unsecure and not recommended for your Server. The official website says:
If set to true all HTTPS URLs will be tried with HTTP instead and no network-level encryption is performed. Enabling this is a security risk and is NOT recommended. The better way is to enable the php_openssl extension in php.ini.
If you don't want to enable unsecure layer in your machine/server, then setup your php to enable openssl and it also works. Make sure the PHP Openssl extension has been installed and enable it on php.ini file.
To enable OpenSSL, add or find and uncomment this line on your php.ini file:
Linux/OSx:
extension=php_openssl.so
Windows:
extension=php_openssl.dll
And reload your php-fpm / web-server if needed!
UPDATE:
As of PHP 7.4 the extension is named extension=openssl (known for Windows).
This issue occurs due to openssl and extension directory so uncomment below extensions in php.ini file
extension=php_openssl.dll
extension_dir = "ext"
Its works on my machine.
I had the exact same problem and couldn't find a solution, so after thinking and looking for a while I figured that my PHP.INI apparently didn't look in the correct directory for my PHP Extensions, so I went under:
"Directory in which the loadable extensions (modules) reside."
And found the following:
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
;extension_dir = "ext"
And simply removed the ; infront of "extension_dir = "ext", note this is only for Windows, remove the semicolon in front of the first extension_dir if you are running a different operating system.
I have no idea why mine wasn't already unmarked, but it's just something to look for if you are having problems.
According to the composer reference there are two relevant options: disable-tls and secure-http, which one can use. Just edit the configuration with: nano ~/.composer/config.json:
{
"config": {
"disable-tls": true,
"secure-http": false
}
}
Then it will complain about:
You are running Composer with SSL/TLS protection disabled.
Warning: Accessing getcomposer.org over http which is an insecure protocol.
But it performs the composer selfupdate (or whatever command).
One cannot simply "enable SSL in the php.ini" on Linux; PHP needs to be compiled with openSSL configured as shared library - in order to be able to access it from the PHP CLI SAPI.
To enable openssl go into php.ini and enable this line:
extension=php_openssl.dll
if you don't want enable openssl you can set to composer not use openssl with this command:
composer config -g -- disable-tls true
however, this is a security problem.
After trying everything, I finally managed to get this sorted. None of the above suggested solutions worked for me. My system is A PC Windows 10. In order to get this sorted I had to change the config.json file located here C:\Users\[Your User]\AppData\Roaming\Composer\. In there, you will find:
{
"config": {
"disable-tls": true},
"repositories": {
"packagist": {
"type": "composer",
"url": "http://repo.packagist.org" // this needs to change to 'https'
}
}
}
where you need to update the packagist repo url to point to the 'https' url version.
I am aware that the above selected solution will work for 95% of the cases, but as I said, that did not work for me. Hope this helps someone.
Happy coding!
I had the same problem. I tried everything listed on this page. When I re-installed Composer it worked like before. I had a PHP version mismatch that was corrected with a new install establishing the dependencies with the PHP path installed in my system environment variables.
I DO NOT RECOMMEND the composer config -g -- disable-tls true approach.
By the way the way to reverse this is composer config -g -- disable-tls false.
I just add this because it worked for me, i install composer with the developer option activate (just check the box in the installer)
https://getcomposer.org/Composer-Setup.exe
I think this problem may occurs when you add a new version of php to your wamp server.
If you do this, you have to check if the extension_dir variable is configure to "env".
Then check if the php_openssl.dll exist in your phpx.x/ext folder. If there is not php_openssl.dll, you have to download it here :
http://www.telecharger-dll.fr/dll-php_openssl.dll.html
If it still not working, check if your apache server use the good php.ini file by running the following cmd command :
php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\wamp64\bin\php\php7.4.7x64\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
If the loaded configuration file return (none), you have to check your appache/apache2.4.41/conf/httpd.conf file is configure with the proper phpIniDir and the correct module.
It must be something like this :
PHPIniDir "${APACHE_DIR}/bin"
LoadModule php7_module "${INSTALL_DIR}/bin/php/php7.4.7x64/php7apache2_4.dll"
Then restart apache and check the "apache/apache2.4.41/bin/php.ini" (wich is the one configure above by PHPIniDir) it must me like
You are running Composer with SSL/TLS protection disabled.
composer config --global disable-tls true
composer config --global disable-tls false
For me on Windows 10 none of those worked ... I had changed my local server from WAMP to Laragon and had to add the new path to the php.ini in the Environment Variables under:
Control Panel --> Advanced System Settings --> Environment Variables --> Path (double click) --> Browse... then navigate to the php.ini and click ok.
After that a reboot was needed and now composer works like a charm!
I had this issue on IIS on my new home server when attempting to install Magento. To fix it i added the above: extension=php_openssl.dll in my php.ini and then restarted my IIS server on Windows 10 Pro.
I was just having this issue, but these solutions weren't working since I installed PHP and Apache independently without Xampp or Wamp.
The problem for me turned out to be that I was trying to run composer from Git for Windows instead of cmd or PowerShell—where it turned out to be working fine.
My solution was to add a symlink from my /c/php/php.ini (C:\php\php.ini) to my /bin/ directory (C:\Program Files\Git\bin).
lot of answers already, but this is what worked for me (in case someone still needs it)
Just upgraded from php 7.3.x to 7.4.33 in Windows 10, and this error occurred to me, so Just went back to the composer.exe installer, re-run the installation process once again pointing to the new php 7.4. folder, and it worked.

Installing YAML for PHP in IIS

I am trying to install the YAML 1.2 extension to PHP 5.6 under IIS 10 (Windows 10). I am using http://pecl.php.net/package/yaml/1.2.0/windows to download the files.
I have downloaded the PHP 5.6 non-thread-safe DLL (x86 to match my version of PHP), copied php_yaml.dll to my extension directory, copied yaml.dll to C:\Windows\System32 (which is reported as one of the paths in phpinfo()) and added extension=php_yaml.dll to my php.ini. I've verified with phpinfo() that the correct php.ini file is being loaded, and commenting out other extensions removes them from the output of phpinfo().
However, YAML doesn't appear in the output of phpinfo() and the functions are not loaded. Running php-cgi.exe -v from the command line gives a warning:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\PHP\php_5_06_14\ext\php_yaml.dll' - The specified module could not be found.
in Unknown on line 0
The file exists at the location specified and the permissions appear to be correct. What else can I do to get it working?
As far as I can tell, the use of PECL as package manager is being in dropping.
Having to install extensions in a server makes things more complicated and it depends on the environment, permissions, etc.
I'm sure someone could help you solve that (I haven't work on windows in years, so I can't)
But, instead I suggest you another solution. Maybe you can opt for it, maybe you have to stick with the extension, but, in case you can actually look for other option, I suggest you to use another library.
https://github.com/symfony/yaml
And, you could use Composer to install your libraries, I suggest you take a look at it.
Again, it may be for you or not, but I think this would be a lot easier.
I hope that helps.
I put the path to my extension directory in the path environment variable. That fixed the issue for me.

"Full REPL not supported. Falling back to simple shell" - error in Laravel While Trying To Use php artisan tinker

My Development Environment:
Windows 7 + WAMP
PHP Version: 5.4.16
While I try to use php artisan tinker - my console give me the following error:
REPL not supported. Falling back to simple shell
I search solution for this and found this :
Full REPL not supported
But this could not helped me much.I know Boris is By default supported by laravel 4.1.
And I might do some changes in php.ini according to this.
If the tinker command doesn't work for you, it is very likely the disable_functions setting in your php.ini contains the needed pcntl_() functions. Put a comment before this line in your php.ini and that should allow tinker to work.
Source :http://laravel-recipes.com/recipes/280
But when I Open my php.ini file the disable_functions contains nothing except this:
disable_functions =
; This directive allows you to disable certain classes for security reasons.
; It receives a comma-delimited list of class names. This directive is
; NOT affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-classes
Is this My WAMP problem? Do I Missing Something !!!
Boris In Tinker
The php artisan tinker command now utilizes the Boris REPL if your system supports it. The readline >and pcntl PHP extensions must be installed to use this feature. If you do not have these extensions, >the shell from 4.0 will be used.
From the Laravel docs here:
http://laravel.com/docs/releases
So basically, they are telling you that php55-pcntl and readline needs to be installed.
Everytime I try to brew install php55-pcntl though, I get
configure: error: Cannot find openSSL's <evp.h>
Try running that and see what you get.
UPDATE: Use Laravel's Homestead environment
I completely gave up trying to run it on a XAMPP/WAMP/MAMP-style localhost.
If you go to the quickstart docs and scroll down to local development environment:
http://laravel.com/docs/quick#local-development-environment
It actually recommends you use Laravel's custom homestead environment:
http://laravel.com/docs/homestead
Read the docs for installing that and report back with results. It has been working perfectly for me.
One or more of readline posix and pcntl extensions are missing. You need to compile PHP with the appropiate configuration options to enabled it.
Here are the instructions:
readline http://www.php.net/manual/en/readline.installation.php
pcntl http://www.php.net/manual/en/pcntl.installation.php
posix http://www.php.net/manual/en/posix.installation.php
Note that posix functions are enabled by default.

Can't install php Composer, complaining about openssl

I'm trying to install Composer. However, it's giving me an error about "...openssl extension is missing..." (please see screenshot)
In my wampserver configuration I've enabled openssl extension (please see screenshot)
Please advice.
The composer download, as far as I remember, uses the PHP CLI (Command Line Interface) so in fact you have to include the php_openssl module into the PHP.INI used by the PHP CLI.
So edit the php.ini in the \wamp\bin\php\phpx.y.z folder. You have to do this manually you cannot use the menu liks on wampmanager.
Just remove the comment # from column 1 of this line
#extension=php_openssl.dll

cannot install or use ZeroMQ library

I am working on Debian Linux / Apache (a VPS at Dreamhost). I have tried to install ZeroMQ (version 3.2.3) as per these instructions. At the first glance, it looks like everything went well.
The sudo make install command proudly reports back that (among others)
Libraries have been installed in: /usr/local/lib
Indeed, here is the ls of /usr/local/lib:
libzmq.a libzmq.so libzmq.so.3.0.0 php python2.5 site_ruby
libzmq.la libzmq.so.3 ocaml pkgconfig python2.6
In order to use ZeroMQ I have added to my php.ini:
extension = /usr/local/lib/libzmq.so
But when I run PHP, I get:
PHP Startup: Invalid library (maybe not a PHP library) '/usr/local/lib/libzmq.so
What am I doing wrong?
update
As per djf's answer, I worked my way through the instructions for PHP bindings (building from Github). Those seem to work. But then, when I run PHP I get:
PHP Warning: PHP Startup:
zmq: Unable to initialize module Module compiled with module API=20060613
PHP compiled with module API=20100525
These options need to match in Unknown on line 0`
Now what?
update 2
Oh, wait a minute. I may know what that is. Dreamhost has PHP 5.2 on the command line. I need PHP 5.4, so I have been calling PHP like so /usr/local/php54/bin/php (this is apparently where the PHP 5.4 executable resides).
However, commands like configure and make use the ordinary, standard PHP. So I needed to upgrade CLI PHP to 5.4.
After that, everything worked. Thanks for the help, everyone!
Seems like you've only installed the C library, hence the error:
PHP Startup: Invalid library (maybe not a PHP library) '/usr/local/lib/libzmq.so
You also have to build the PHP bindings. Check these instructions on howto build them.
I do this for windows but i thinks linux is same.
Just go to http://pecl.php.net/package/zmq/1.1.2/windows and download package that fit with your php version.
Then extract it and coppy 'libzmq.dll' to 'xampp/php' folder, 'php_zmq.dll' to 'xampp/php/etc'.
At the end of 'php.ini' add following line:extension=php_zmq.dll
Don't forget restart your xampp!Good luck

Resources