Laravel - artisan command not working - php

I am getting started with using laravel on Mac and am using MAMP. I am using the `artisan' command with laravel in php.
php artisan migrate:make create_users_table --table=users --create
But it is giving me this error
php artisan migrate:make create_users_table --table=users --create
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so, 9): image not found in Unknown on line 0
Laravel requires the Mcrypt PHP extension.
I have installed the mcrypt extension for PHP.
brew install php53-mcrypt
This gives me a message saying that it is already installed: php53-mcrypt-5.3.26 already installed

PHP being different when run in the command line versus through your web server turns out to be a pretty common issue (note that those are three separate links with possible solutions :D)
The key point is to:
make sure the correct PHP binary (the one used by MAMP) is in your PATH
(less likely) to check to see if your CLI-run php.ini and loaded extensions is different from your web-server (apache)-run PHP (They can be potentially different).
Finally, please consider saving your time and some stress by using Vagrant or another VM provider, which gives you the ability to run a "real" web server on your computer without mucking up your Mac OS install!

Related

showing two different PHP versions in command line

I installed laravel project 5.1 which is working fine but artisan commands are not working throwing each() error which is deprecated in php 7.1. When I run phpinfo() it shows php version 5.6 and on command line there's also two versions are showing
when run
phpinfo();
5.6
when run on command Line in xampp folder
C:/xampp> php -v;
5.7
when run in command in this xammpp/php directory
C:/xampp/php> php -v;
5.6
This is because there are CLI version and WEB version.
How Giacomo1968 says in this answer on Super User:
“Don’t panic! If you are concerned about what PHP version your Apache server is using, the output of phpinfo() is always what you should pay attention to. The Apache PHP module and the PHP command line binary are two different things that don’t interfere with each other.
In fact you can compile and load various PHP versions you want to work with Apache as long as you adjust Apache to properly load it. The PHP command line interface will never come into play in the case of Apache parsing PHP pages.
The command line version of PHP is simply there for command line specific tasks and the PHP module for Apache will never touch, use or need that.”

Where does PHP Composer store path to PHP binary?

My Windows 7 PC for some reason will not load the PHP cURL module regardless of which WAMP server software package I install. This isn't a huge issue most of the time as most libraries will use an alternative function.
My question is about this message I get in my terminal window when I run composer commands on packages that try to use curl....
PHP Warning: PHP Startup: Unable to load dynamic library 'G:\php\ext\libcurl.dll' - %1 is not a valid Win32 application.
Notice above in the error I get from composer it is referencing my G drive G:\php\ext\libcurl.dll. My current dev server and active PHP is located in my E drive here E:\Dev_Server\php
I checked my Windows PATH property to make sure a reference to the old G drive PHP wasn't stuck in there somewhere and it is not. My new E drive is in my path. So I am wondering where Composer is storing the G drive PHP reference so I can update that, any ideas?
PHP CLI (which Composer uses) and PHP WAMP (which, well, WAMP uses) use different configuration files. Composer by itself does not store anything about your PHP installation.
What to do: Run php --ini and php -i | more from command line (cmd.exe). Check which configuration files PHP CLI uses and check what is configured there. You probably will find references to your G: drive there.

laravel 4 artisan make command - error Mcrypt PHP extension required

I'm trying to glean a signal from the noise in debugging this.
When I run ./artisan make:middleware MyTools, I get:
Mcrypt PHP extension required
Solutions seem to revolve around setting a proper value in /etc/php5/mods-available/mcrypt.ini and then doing a php5enmod mcrypt and Apache restart. Sounds good, and a phpinfo() call shows it's there and that I'm running PHP 5.5.9-1ubuntu4.20. All peachy.
However, I'm not running php 5 on the command line for artisan! Typing php -v tells me I'm running php 7.0.14-2.
When I go to /etc/php/7.0/mods-available, indeed I do not see mcrypt.ini - my question is how to "get" a proper mycrypt.ini file in there, have Mcrypt running for the COMMAND LINE, and not have to change anything else - for example I want to leave the webserver as it is at 5.5.9. How do I do this?
-- UPDATE --
See the discussion/comments below, I was able to get around this by DOWNGRADING my CLI to 5.5.9 vs. installing mcrypt into php7. This is not likely the best solution and I welcome a better one.

Laravel 5 memcached not found while properly installed

I have PHP 5.4 on a litespeed web server. PHP has been compiled properly with memcached module and we also installed properly memcached library.
In fact the problem suddenly happened without any change at all (server side) when I run the artisan command, I am getting this error:
PHP Fatal error: Class 'Memcached' not found in /laravel/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php on line 52
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Memcached' not found
I googled the issue but was unable to find a solution. I am using Laravel 5.0.
I edited the app/Http/Routes.php and returned new Memcached at the top of the file and the php object was returned so it means memcached is properly installed on the server...
Any help would be appreciated.
Found the solution. My problem was when I was running the artisan command, the artisan was using another version of PHP (different than the Litespeed one) and this PHP was not compiled with memcached.

Error installing Laravel 4 with composer

When I try to install Laravel 4 via Composer, I get the following message in Terminal
Mcrypt PHP extension required. Script php artisan optimize handling
the post-install-cmd event returned with an error
The PHP version on my computer is 5.5.3 and when I run phpinfo it shows that mcrypt is enabled. When I run the which php command in Terminal it shows
/usr/bin/php
I therefore extended the $PATH with .bash_profile.
export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH
Unfortunately, the which php command still shows /usr/bin/php after extending $PATH. And as a result the error is still there.
So I am out of ideas on how to solve this issue. Does anyone have an idea? Thanks!
There is difference between the MAMP PHP version and you "Terminal" PHP version. Therefore are you probably setting up the export path.
When you are changing the export path you have to restart your terminal before it will take effect on your computer.
I am not sure of this but when your error is appearing and older version of Laravel will be installed.
What do you get when you execute: php -v in your terminal?

Categories