Homebrew: Install php mcrypt - homebrew

I have, possibly like 1000k+ others, problems with homebrew after their move to a different structure.
I have installed homebrew and after that php with:
$ brew install php
Here I got php 7.2 version.
In this version I'm missing some modules, like xdebug, mcrypt and some others.
Question: how can I get them installed via homebrew?????????????????
There is no right documentation for that. Not at homebrew php-package site, not anywhere.
I need this all for my project and there is no time for switching back to native packages.
Thanks guys for your support!!!

It appears that as of 31rst March 2018, the homebrew-php is deprecated and all php libraries will be part of homebrew/core.
This also means that:
Forgive my stupid question, I'm not sure I understand: there won't be a php71-mcrypt, but there may be a php-mcrypt, as long as it accepts any installed php package?
There won't be either but we'd accept the php or php#7.1 formula installing mcrypt by default.
In the announcement, you also mentioned the CI workload as a reason for deprecating the tap. Until the tap is officially archived, would it make sense to limit formula updates to supported PHP versions (at this time, 5.6, 7.0, 7.1 and 7.2) in order to reduce CI workload and bottle builds?
I don't want to dictate how this tap is run pre-deprecation. That might not be a bad idea but given the tap is going away in a few months I think it's fine as-is until then.
In other words, mcrypt is now installed by default. See Zaph's comment on the other answer for a more detailed explanation.
I'm not sure about xdebug, but you might want to check there.
https://github.com/Homebrew/homebrew-php/issues/4721
p.s. You can check which modules are installed with php -m

#caspertm I just did a clean reinstall of Homebrew PHP and mcrypt isn't included at all.
~ ᐅ php --version
PHP 7.2.4 (cli) (built: Apr 19 2018 16:42:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies
~ ᐅ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
~ ᐅ which php
/usr/local/bin/php
Did I miss something? It seems like, to make things easier on their end, the Homebrew folks have screwed over the PHP developers who rely on this...
PECL works, sorta, (mcrypt doesn't install with PHP 7.2.x because nothing's marked as "stable" in that case, but xdebug installs. I haven't tested anything else,) and that might be enough for some, but it sounds like OP can't/doesn't want to use that for some reason?

Related

Install specific version of apt package for specific ubuntu version

I want to install package foo version 1234 in a docker container. I prefer this to the latest version, as it will always work the same way.
So my Dockerfile has this:
RUN apt-get update && apt-get install -y foo=1234
But the base image is mongodb:4.0.2, which is layered on Ubuntu xenial.
When I build the image, the apt install fails because it cannot find that version. I think xenial doesn't support that version.
So how do I find the latest supported version of a package foo on xenial? If I run apt policy foo it shows me the latest for the ubuntu I'm using (bionic), not for xenial.
If the package at stake is, say, rlwrap, you could just take a look at the webpage https://packages.ubuntu.com/xenial/rlwrap
But if you want a proper way to get this version info programatically, you can rely on the Launchpad API, which comes with an official API client implemented as a Python library.
Otherwise, you can directly query the API with tools such as curl and jq (to parse the retrieved JSON data):
$ curl -fsSL "https://api.launchpad.net/1.0/ubuntu/+archive/primary?ws.op=getPublishedSources&source_name=rlwrap&exact_match=true&distro_series=https://api.launchpad.net/1.0/ubuntu/xenial" \
| jq --raw-output ".entries | .[0] | .source_package_version"
→ 0.41-1build1
As mentioned in this Askubuntu question, a similar API exists for Debian as well.

Homebrew: install new formula php72-imagick

I need install imagick module on my php 7.2
I see
brew search php72
==> Searching local taps...
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...
No formula found for "php72".
Closed pull requests:
...
php72-imagick 3.4.3 (new formula) (https://github.com/Homebrew/homebrew-php/pull/4267)
How can I do it?
Also I need support for argon
It all changed back in April 2018 I think. Homebrew no longer acts as the package manager for PHP, so all the php-imagick and php-redis and php-other-extension stuff has gone and you are now supposed to manage PHP packages using pecl like everyone else does.
So, how to get Imagick under PHP? Note that Imagick and ImageMagick are two different things:
ImageMagick is the entire ImageMagick suite
Imagick is just the PHP binding
Here are the steps - if anyone knows better or any improvements, let me know via comment and I will update.
Step 1 - Delete anything likely to conflict
Before starting, it is best to clean up all the stuff that is broken or unneeded. Do as many of these as you are comfortable with:
brew rm php php#5.6 php#7.0 php#7.1
brew rm imagemagick
Step 2 - Update Xcode command line tools and get build packages
Make sure you have installed Xcode command-line tools with:
xcode-select --install
Go to AppStore and click on Updates and update any Xcode related packages - especially if you have recently upgraded macOS.
Install homebrew building tools:
brew install pkg-config
Step 3 - Install ImageMagick
Check what ImageMagick options you want with:
brew options imagemagick
I like to use:
brew install imagemagick --with-x11 --with-librsvg --with-openexr --with-pango
hash -r
but you may like vanilla install:
brew install imagemagick
hash -r
Step 4 - Install homebrew PHP
Next, install the homebrew version of PHP with:
brew install php
hash -r # Update bash's internal paths
Now, critically ensure you are running the correct homebrew PHP:
type php
If that tells you:
/usr/local/...anything.../php
you are running homebrew PHP and you can go to the next step.
If it tells you:
/usr/bin/php
you are running the Apple-supplied PHP. If that is what you want to run, ignore my entire answer which is predicated on you wanting to use homebrew PHP. If you get this answer but want to run homebrew PHP, your PATH is set incorrectly. You need to put /usr/local/bin before /usr/bin to pick up all homebrew packages ahead of Apple programs, i.e.
export PATH=/usr/local/bin:$PATH
This step gives you pecl - the PHP Package Manager - as well, since it is part of homebrew PHP.
Step 5 - Install Imagick
Now you can install Imagick with pecl:
pecl install imagick
If anything goes wrong, here are some related questions and answers...
Q1. How can I find where my php.ini file is?
Try any of these commands:
pecl config-get php_ini # I get "/usr/local/etc/php/7.2/php.ini"
brew info php
php -i | grep "Loaded Configuration" # I get "Loaded Configuration File => /usr/local/etc/php/7.2/php.ini"
Q2. How can I find where pecl installs modules?
pecl config-get ext_dir # I get "/usr/local/lib/php/pecl/20170718"
Q3. How can I tell what PHP modules are loaded?
php -m
Q4. Why can't PHP find my module?
First locate your modules directory using Q2. I like to put that in the clipboard with:
pecl config-get ext_dir | pbcopy
Then edit the php.ini file from Q1. I use vi, so I would do:
vi "$(pecl config-get php_ini)"
Then find the line in that file that looks like this:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
and, then (using the contents of your paste buffer) make the following line look like this (no semi-colon at the start):
extension_dir = "/usr/local/lib/php/pecl/XXXXXX"
on my machine XXXXXX is 20170718. If you get this right, any and all modules you install via pecl will be visible to your homebrew PHP.
Q5. How can I see all my PHP settings?
Check PHP configuration, versions and settings with:
php -i
In my case (PHP 7.2.10 with Homebrew) works:
pecl install imagick
Open the file php.ini and remove extension line with imagick extension.
Check *.ini files with
php --ini
You can see paths to extension files. Create or edit imagick ini file.
subl /usr/local/etc/php/7.2/conf.d/ext-imagick.ini
The content of file may be (check the path to imagick.so)
[imagick]
extension="/usr/local/opt/php/pecl/20170718/imagick.so"
And restart php with
brew services restart php
Try, if the error message dissapear:
php -v
And check imagick extension with:
php -i | grep imagick
If you see line with imagick module => enabled you have solved a problem.
You want php72-gmagick, GraphicsMagick is a fork from ImageMagick 5.5.2.
Or, you can pecl install imagick still.

Running ASP.NET Core app from Amazon Linux 2 on Docker - Globalization

I have my ASP.NET Core app running beautifully (more or less) on microsoft/aspnetcore:2.0-jessie. Now I want to try to get it to deploy to amazonlinux:2.
So far, the biggest hurdle has been libicu. I tried setting Globalization to Invariant, but this caused weird failures in, e.g., mySQL database calls.
Here's the relevant step from my Dockerfile:
RUN curl -L --http1.1 http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-RHEL6-x64.tgz --output icu.tgz \
&& tar -xf icu.tgz -C / \
&& export LD_LIBRARY_PATH=/usr/local/lib \
&& rm icu.tgz
(SourceForge was down while I was trying to work on this yesterday, which didn't improve matters.)
In any case, I still get the message of doom from .NET Core:
FailFast: Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
Any suggestions how to proceed?
Well, I revisited this yesterday. I don't know if it's because the base .tar of the Amazon Linux image has been updated, or because I was doing something wrong last time, but I installed the following packages using yum and all was well:
libunwind
libicu
dotnet-hosting-2.0.5
Note that for the dotnet package I needed first to set up Microsoft's package repository for yum, i.e.
rpm --import https://packages.microsoft.com/keys/microsoft.asc
and copying the following file to /etc/yum.repos.d/dotnetdev.repo :
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
(see Microsoft's instructions for CentOS and other Linux distros)

Icingaweb2 on a Server doesn't start

So, I installed Icingaweb2 on a Ubuntu 16.04 server, but when I type in the IP/icingaweb2 I only get the message
<?php
/*! Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
require_once '/usr/share/php/Icinga/Application/webrouter.php';
and not the Icingaweb2 Interface.
Did I forget to configurate something? Please help.
It's a PHP issue, need to upgrade to 7.0.
Run this:
apt-get -y install php7.0 libapache2-mod-php7.0
The underlying problem here is that Ubuntu 16.04 behaves differently when it comes to loading the PHP module. As such the packages require a specific fix only applied for 16.04
There was a discussion in German over here which turned into a research what changed with the latest Ubuntu release. One thing is - they prefer mpm_event over mpm_prefork as a module. The problem is - the PHP apache module is only compiled for mpm_prefork support but fails heavily when used with mpm_event (see this thread as well).
While the Ubuntu package may satisfy the dependency issues, it cannot forcefully change the mpm* modules. So now we have an open issue for Icinga Web 2 in order to update the documentation for making it work on Ubuntu 16.04. Until this is done please kindly check this solution.
apt-get install libapache2-mod-php7.0 php7.0-dom php7.0-gd
vim /etc/php/7.0/apache2/php.ini
<set timezone>
#set the correct worker
a2dismod mpm_event
a2enmod mpm_prefork
systemctl restart apache2
The PHP module is not compiled for supporting the mpm_event module at this time. PHP 7.0 itself may be thread-safe but not anything else running in that context of the apache webserver then. Not sure why Ubuntu chooses to not set mpm_prefork by default - upgrades pretty much hurt and I couldn't find any good changelog for that.

Why is PHP CodeSniffer Freezing?

I'm a Junior Programmer where I work. Our website was written using PHP 4. We're migrating from PHP 4 to PHP 5.3. There are roughly 5000 PHP files in around 595 directories. So, as you can imagine, the scope of this project is pretty huge.
We use Subversion for version control. I have two separate checkouts. I have two VMs that act as separate webhosts - one stack emulates our actual webserver (CentOS 4, PHP4, etc) and the other is a PHP 5.3 stack (Ubuntu 12.04 LTS).
I took the time to check the files for basic syntax errors using the following commands:
Edit: I ran the following recursive searches from the root of the website.
find ./ -type f -name \*.php -exec php -l {} \; < ~/php5_basic_syntax_assessment.txt
find ./ -type f -name \*.inc -exec php -l {} \; < ~/php5_basic_syntax_inc_assessment.txt
I realize that using php -l to check basic syntax doesn't reveal deprecated code structures/functions and doesn't provide warnings (IE: use preg_slice() instead of slice()). Therefore, I decided to install PHP CodeSniffer.
First, I installed PEAR: [I accepted all the default parameters]
cd ~/
mkdir pear
cd pear
wget http://pear.php.net/go-pear.phar
php go-pear.phar
Next, I installed git:
cd ~/
sudo apt-get update
sudo apt-get install git
Next, I installed PHP Code Sniffer
pear install PHP_CodeSniffer
Finally, I installed the following PHP 5.3 Compatibility standards for the PHP Code Sniffer:
git clone git://github.com/wimg/PHP53Compat_CodeSniffer.git PHP53Compatibility
I did all of the above so that I could assess the 5K PHP files in an automated kind of way. It would be extremely tedious and time consuming to go through each file to make sure they manually follow the PHP 5.3 coding standards.
Finally, here's the command I used to run the PHP Code Sniffer:
phpcs --standard=/home/my_user_name/PHP53Compatibility -p --report-file=/home/my_user_name/php53_assessment.txt /path/to/web/root
To make sure that the specific standards aren't the problem, I also ran the PHP Code Sniffer using the default standards:
phpcs -p --report-file=/home/my_user_name/php53_assessment.txt /path/to/web/root
Either way, the reports freeze in the same place. I've been awake for over 24 hours. I waited for 18 hours before stopping the first run by using CTRL+C. The second is still running and has been running for about an hour and a half.
So, what is causing my PHP Code Sniffer to freeze?
All help is very much appreciated.
Bit late, but I ran into the same issue. Limit the files to just PHP files should do the trick: phpcs -p -- ./**/*.php

Resources