Problems running init as part of yii 2 install - mamp

I am installing yii 2 on a mac. I have mamp pro (3.0.7.3 latest) when i go to the command line and run.
php init i get a message saying
The mcrypt PHP extension is required by Yii2.
I checked the server using phpinfo() and it shows mcypt enabled. I checked the php.ini and it is listed and the file exists in the referenced directory.
any ideas anyone ??

This probably means that your php CLI (Command Line Interface) does not use the same php.ini than MAMP. You could use something like php -c /path/to/mamp/php.ini to be sure to use the same php.ini.
Or try the following command : php --ini, this will show you configuration file names, e.g. :
Configuration File (php.ini) Path: /path/to/php/conf
Loaded Configuration File: (none)
You could then make a symbolic link :
cd /path/to/php/conf
sudo ln -s /path/to/mamp/php.ini php.ini

Related

getting "command not found: phalcon" after successfully installing phalcon/devtools via composer

Software: MacOS
Phalcon: 5.0.0RC4
Phalcon/Devtools: 4.2.0
I have newly created phalcon 5.0 repository.
I successfully ran
composer install
composer require phalcon/devtools
however when I try to run a phalcon command I get
zsh: command not found: phalcon
I checked if it had installed successfully and tried reinstalling as well.
php -m returns that phalcon is installed too:
php -m | grep phalcon
phalcon
and the extension is there in the php.ini file
extension="phalcon.so"
Am I missing anything?
The phalcon/devtools package links the phalcon.php executable to your composer bin-dir.
Get it as follows:
composer config bin-dir
It defaults to ./vendor/bin. The installed symlink is ./vendor/bin/phalcon.php.
You can run the command as follows:
./vendor/bin/phalcon.php [..]
To ease access you can automatically add ./vendor/bin to your PATH (i.e. with direnv)
# .envrc
PATH_add ./vendor/bin
or you can create a ./bin dir in your project directory and symlink phalcon.php as phalcon into it.
mkdir ./bin
ln -sfn ./vendor/bin/phalcon.php ./bin/phalcon
Now you can add ./bin to your PATH:
export PATH="${PWD}/bin:${PATH}"
And invoke the phalcon CLI with:
phalcon [..]
Adding to Nicolai's answer, it is also possible to just call phalcon like so:
vendor/bin/phalcon commands
In my case, I didn't want to be able to call phalcon globally so I copied the file into the project directory and named it phalcon4
Then I edited the paths inside the file like so
$addpath = '/vendor/phalcon';
$GLOBALS['_composer_bin_dir'] = __DIR__ .$addpath;
$GLOBALS['_composer_autoload_path'] = __DIR__ .$addpath. '/..'.'/autoload.php';
// the rest of the code
include __DIR__ .$addpath. '/..'.'/phalcon/devtools/phalcon';
Now I can run the command like this:
php phalcon4 commands
Still, devtools 4.2 cannot run with phalcon 5 so the command just threw an error.

How to enable pcntl extensions in MAMP pro?

I am using laravel/horizon with Osx MAMP pro
when I run the composer it requires laravel/horizon:~1.0
it shows a message -
laravel/horizon v1.0.8 requires ext-pcntl * -> the requested PHP
extension pcntl is missing from your system.
I checked the folder /Applications/MAMP/bin/php7.1.1/php/ext,it doesn't contain pcntl extension.
How can I install that?
download php from http://www.php.net/releases/
tar -xzvf php-7.2.1.tar.gz
cd php-7.2.1/ext/pcntl
/Applications/MAMP/bin/php/php7.2.1/bin/phpize
as # drewjoh metioned ./configure --with-php-config=/Applications/MAMP/bin/php/php7.2.1/bin/php-config --prefix=/Applications/MAMP/bin/php/php7.2.1/bin/php
make && make install
the terminal shows
Installing shared extensions: /Applications/MAMP/bin/php/php7.2.1/lib/php/extensions/no-debug-non-zts-20170718/
open MAMP PRO menu->File ->Edit Template->PHP->7.2.1 add extension=pcntl.so at the end of the php.ini file .
run the command php --ri pcntl and shows
pcntl pcntl support => enabled
Just an addition. Perhaps you followed the above step and still can't get it installed to /Applications/MAMP/bin/php/php7.2.1/lib/php/extensions/no-debug-non-zts-20170718/. Here is something I did that worked for me.
I added the --with-php-config before the --prefix flag and it worked. See step below.
download your MAMP php version from http://www.php.net/releases/ Mine is php7.2.22
Open your terminal and cd into your download folder. Then run this command to decompress the tar.gz file
tar -xzvf php-7.2.22.tar.gz
Cd into the pcntl directory after decompressing.
cd php-7.2.22/ext/pcntl
Run the next line from your terminal to Configure for PHP Api, Zend Module Api, and Zend Extension Api.
/Applications/MAMP/bin/php/php7.2.22/bin/phpize
Then run
./configure --with-php-config=/Applications/MAMP/bin/php/php7.2.22/bin/php-config --prefix=/Applications/MAMP/bin/php/php7.2.22/bin/php; make && make install;
You should see
Installing shared extensions: /Applications/MAMP/bin/php/php7.2.22/lib/php/extensions/no-debug-non-zts-20170718/
Then you can repeat the last two steps above.
You can download the precompiled extensions from here https://github.com/khanakiaphp/mamp_extensions

Protractor still not available after global npm installation

Now I'm having other issues where Protractor is not found after installing using npm -g .
Some background:
I was previously having issues with npm installs, but it works now that I have set the correct proxy settings at the client site - i.e. .npmrc file exists under c:\Users(myUserName) which contains the registry and proxy keys.
For example, I install Protractor as follows :
C:\Projects\prot-test>npm install -g protractor
C:\Users\...\AppData\Roaming\npm\webdriver-manager -> C:\Users \...\AppData\Roaming\npm\node_modules\protractor\bin\webdriver-manager
C:\Users\...\AppData\Roaming\npm\protractor -> C:\Users\...\AppDataRoam
ing\npm\node_modules\protractor\bin\protractor
C:\Users\...\AppData\Roaming\npm `-- protractor#4.0.9
However, as soon as I check the installation, it cannot find it :
C:\Projects\prot-test>protractor --version
'protractor' is not recognized as an internal or external command, operable program or batch file.
****** UPDATE ******
It does appear to be a Win 7 environment issue with PATH not getting updated (i.e. I'm pretty much on lock-down at the client site).
For example, manually navigating to ..\npm directory seems to be required :
C:\Users\..\AppData\Roaming\npm>protractor --version
Version 4.0.9
C:\Users\..\AppData\Roaming\npm>
Your advice is appreciated....
Bob
Yes, its a PATH issue on Windows machines.Make sure if you have below configured in your system variables.
PATH
C:\Program Files\nodejs;C:\Users\<<user>>\AppData\Roaming\npm;
NODE_PATH
C:\Users\<<user>>\AppData\Roaming\npm\node_modules
If it still doesn't work for you still, check if you have all the path semi-colon seperated

pg_ctl: error while loading shared libraries: libpq.so.5

I'm trying to get postgres server status with:
sudo /etc/init.d/postgres status -u postgres
But getting following error:
/home/alex/olddisk/usr/local/pgsql/bin/pg_ctl: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
I added:
export LD_LIBRARY_PATH=""
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/alex/olddisk/usr/local/pgsql/lib/"
to my .bashrc, but it didn't help.
Thank you.
I ran into this error when I built postgresql from source using the --prefix flag. Building from source installs the necessary shared libs to the libs folder under the prefix directory you specified, instead of the usual place installations put shared libs. To solve the problem I just added the [prefix].libs folder to the LD_LIBRARY_PATH environment variable. For example, after building postgres using --prefix /mike/sandbox/postgres, the below command solved the issue:
export LD_LIBRARY_PATH=/mike/sandbox/postgres/lib:$LD_LIBRARY_PATH
I think this issue is duplicated, I faced the same problem and posted a solution here.
try this:
1: Know the path of "libpq.so.5"
find / -name libpq.so.5
Output example: "/usr/pgsql-9.4/lib/libpq.so.5" If found nothing, check if you have already installed the suitable postgresql-libs for your postgresql version and your OS platform
2: Symbolic link that library in a "well known" library path like "/usr/lib":
ln -s /usr/pgsql-9.4/lib/libpq.so.5 /usr/lib/libpq.so.5
Attention: If your platform is 64 bit, you MUST also symbolic link to 64 bit libraries path:
ln -s /usr/pgsql-9.4/lib/libpq.so.5 /usr/lib64/libpq.so.5
3: Be happy !
Please ensure you have 'postgresql94' package installed as well (in addition to postgresql94-server, postgresql94-lib, postgresql94-devel and whatever other PG related package you already have). These libraries get installed along with that package.
Some ideas:
Your modified ~/.bashrc only takes effect when you start a new (interactive) shell. Though catching up on that will not help you because:
/etc/sudoers, your configuration file of sudo, probably specifies env_reset. This means, that /etc/init.d/postgres will not see the content of $LD_LIBRARY_PATH of your shell.
Insert debug statements in /etc/init.d/postgres to verify what I told you: echo "LDPATH: $LD_LIBRARY_PATH" >&2
Check /etc/init.d/postgres. Probably you will have to insert the third one of your export statements near the start of this script. Or you will have to update an existing export LD_LIBRARY_PATH= statement.
Have you installed the necessary libraries?
If you are using ubuntu try:
sudo apt-get install libpq libpq-dev

Mac osx Lion phpunit require(/usr/lib/php/PHPUnit/Autoload.php)

I am migrating to a new computer moving from snow leopard to lion at the same time. phpunit did not seem to make the migration, so I have reinstalled it. However the standard install with pear seems to not work with my home brew install of php. Here is the error:
phpunit
PHP Warning: require(/usr/lib/php/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43
Warning: require(/usr/lib/php/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43
PHP Fatal error: require(): Failed opening required '/usr/lib/php/PHPUnit/Autoload.php' (include_path='.:/Users/bimemployee/pear/share/pear:/usr/lib/php') in /usr/bin/phpunit on line 43
Fatal error: require(): Failed opening required '/usr/lib/php/PHPUnit/Autoload.php' (include_path='.:/Users/bimemployee/pear/share/pear:/usr/lib/php') in /usr/bin/phpunit on line 43
I have my computer setup with my main /etc/php.ini file as a symlink to the home brew php.ini file at /usr/local/etc/php.ini this contains my include path which seems to be working.
php -r 'foreach (explode(":", get_include_path()) as $path) echo $path . PHP_EOL;'
No log handling enabled - turning on stderr logging
Cannot find module (LM-SENSORS-MIB): At line 0 in (none)
.
/Users/bimemployee/pear/share/pear
/usr/lib/php
I am also setting up php to work with the homebrew version via the .bash_profile file.
export PATH="$(brew --prefix)/bin:$PATH"
which php
/usr/local/bin/php
which phpunit
/usr/bin/phpunit
Thanks for any help.
-Cory
Maybe you don't have the latest version or the full phpunit installation. You need to install all dependencies using --alldeps
So you should install phpunit like this:
pear channel-discover pear.symfony.com # for Yaml dependency
pear channel-discover pear.phpunit.de
pear install --alldeps phpunit/PHPUnit
This work for me ;)
The problem you having might be connected with your include_path, actual (real) php lib directory and with brew link command.
Brew installs php lib into Cellar directory and than links (brew link) all existing resources to /usr/local/lib/php (or /usr/lib/php - depending on your installation).
The problem is File.php and File/ appears in Cellar php lib after linking process (probably after pear update/upgrade). That means it will be not linked in /usr/local/lib/php.
To fix it you can simply brew unlink and brew link again.
Additionally it would be good to set your pear php_dir to /usr/local/lib/php. This way all new pear modules will be installed in correct destination without linking process. This makes nice separation between custom Pear modules and PHP lib itself.
You need to set your php include path in php.ini so that it includes the PEAR directory where PHPUnit lives.
include_path = ".:/Applications/MAMP/bin/php/php5.3.6/lib/php:"
You may need to search for Autoload.php using spotlight to find the right location.