guard-laravel reports "phpunit is not installed on your machine" - laravel

I'm using Jeffrey Way's wonderful Laravel-Guard on a Laravel 4 project I'm building, and for the most part, it seems to be working as intended, except for when I try to get the phpunit part working.
Upon running guard, and editing a file, I get this in the console:
19:49:53 - ERROR - phpunit is not installed on your machine.
I've tried two things to make this work, first I tried installing phpunit via composer, then I tried installing it via PEAR - neither worked.
I'm running Debian 7.
Can anyone help? Thank you.

What error message do you get?
See this question on installing php-unit via composer. Notice the path to phpunit. You may want to alias that to phpunit command works anywhere.
Alternatively, you may need/want to install it globally. I've had luck installing it via a package manager. edit: You may have already tried this method :/
$ sudo apt-get install php-pear # The same on Debian ??
$ sudo pear upgrade PEAR
$ sudo pear config-set auto_discover 1
$ sudo pear install pear.phpunit.de/PHPUnit
Note: May need PEAR dependencies, see here: http://www.giocc.com/installing-phpunit-on-ubuntu-11-04-natty-narwhal.html

I don't know about Laravel-Guard specifically, but I found the easiest way to install phpunit without needing to do anything with PEAR was to do a stand-alone composer-based install.
I created a directory /opt/phpunit (because I couldn't think of anywhere better to put it), and then created the file /opt/phpunit/composer.json:
{
"require": {
"phpunit/phpunit": "3.7.*"
},
"config": {
"bin-dir": "/usr/local/bin/"
}
}
You may need to adjust the bin-dir setting to match somewhere on your path. This is critical - otherwise anything looking for phpunit will not be able to find it.
Then you can just run composer install - it will download phpunit for you and put a symlink to the launch script in /usr/local/bin,
dev1:~$ which phpunit
/usr/local/bin/phpunit
Where (on my machine) /usr/local/bin/phpunit becomes a symlink to /opt/phpunit/vendor/phpunit/phpunit/composer/bin/phpunit
... and it just works. Of course, you will need to manually update occasionally using composer update to get the latest phpunit code.
I got these instructions from here: Chapter 3. Installing PHPUnit

Related

postgresql uuid-ossp.control file missing in extention folder. I have installed postgres 9.6 on windows 10

I am getting the below error on running this query CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
SQLSTATE[58P01]: Undefined file: 7 ERROR: could not open extension control file "C:/Program File
s/2ndQuadrant/PostgreSQL/9.6/share/extension/uuid-ossp.control": No such file or directory (SQL:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp")
Old question but I found it when I had a similar problem.
To install the uuid-ossp extension, you need to have some extra modules installed on the server you're on.
You can get those modules by installing postgresql-contrib, for example, on a Red Hat server, you'd do
sudo yum install postgresql-contrib
Also, note that if you need specific Postgres versions of the modules, you can do something like:
sudo yum install postgresql13-contrib
I had this problem and the first answer solved it for me.
Probably you are missing modules.
sudo yum install postgresql-contrib and try again.

Installation of Xdebug on MacOS Catalina 10.15

I tried to install Xdebug on OS X 10.15 and run into following problem:
/private/tmp/pear/install/xdebug/xdebug.c:25:10: fatal error: 'php.h' file not found
I tried to fix the problem like described here: Installing xdebug on MacOs Mojave - 'php.h' file not found
Unfortunately the header files cannot be found in this directory: /Library/Developer/CommandLineTools/Packages
Any ideas where I can get the current header files for OS X 10.15?
Update
For anyone that just want xdebug support on MacOS, most of the instructions in this answer are not necessary when using the built-in version of PHP. Before doing anything, you should check if xdebug.so already exists in /usr/lib/php/extensions/no-debug-non-zts-20180731/, which should be there by default. If so, you can skip to the Enabled support in PHP portion of this answer.
Using Homebrew is also an acceptable solution for you (and can also prevent other issues).
For anyone else looking to actually build binaries on MacOS and get the header error, the full answer is for you. It also answer OP question directly. Note building xdebug from source code and actually trying to use that version of xdebug.so with the build-in PHP should end up in a "code signature" error. As described here and here, the only real solution would be to compile and use you own instance of PHP instead of the built-in one. In any situation, using Homebrew would be easier.
tl;dr
Apple decided to remove headers file in /usr/include and the macOS_SDK_headers_for_macOS_10.14.pkg package. To install Xdebug, you'll have to manually compile Xdebug with the correct reference in both phpize and make.
For more details, I wrote a blog article about the issue and the solution
Original Answer:
Long story short, Apple decided to nuke /usr/include in MacOS Catalina, which has been the default location for C header file for ever in UNIX systems. Trying to install through PEAR / PECL will return an error as the compiler will look for necessary headers file in /usr/include. So the solution is to compile Xdebug manually, manually specifying the actual location of the header files, which are still provided by Xcode, just at a different location.
First, make sure Xcode is installed, including the command line tools. The following command will display the location of the default SDK :
$ xcrun --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
The header you'll want (php.h) will then be in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/main.
Getting source
Let's compile 2.7.2, getting the source code from git. Alternatively, you can download the source from Xdebug site.
git clone https://github.com/xdebug/xdebug.git
cd xdebug
git checkout tags/2.7.2
phpize
Next we need to make a copy phpize so we can edit the include path :
cp /usr/bin/phpize .
nano ./phpize
Find this line :
includedir="`eval echo ${prefix}/include`/php"
...and replace it with this line :
includedir="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php"
Run phpize:
./phpize
You should now see something like this :
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
Configure & build
We can now configure :
./configure --enable-xdebug
...and run make using our custom SDK location defined as compiler flags :
make CPPFLAGS='-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/main -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/TSRM -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/Zend -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/ext -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/ext/date/lib'
Might see some warning, just ignore it for now. Finally, we'll need to run :
make install
Again, this command will fail because it can't move the extension to the right place. SIP will prevent it. But no worries, we'll take care of that manually at the next step. make install is still required as it will sign the *.so file.
Enabled support in PHP
Next, we move the executable somewhere safe. I use /usr/local/php/extensions.
sudo mkdir -p /usr/local/php/extensions
sudo cp /usr/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so /usr/local/php/extensions
Then we edit the PHP configuration to enable Xdebug. Simply edit php.ini:
sudo nano /etc/php.ini
And we add the following at the bottom :
[xdebug]
zend_extension=/usr/local/php/extensions/xdebug.so
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
Restart built in server to be sure :
sudo apachectl restart
And finally test everything went fine :
php -i | grep "xdebug support"
If the above command returns nothing, then Xdebug is not available on your install. Go back the steps to find out what's missing.
Note:
A more complete fix would be to edit the result of php-config --include-dir, which returns /usr/include/php. That would make any installation find the necessary header files without having to manually edit files or compiler flags.
If you are using brew, I solve this by reinstalling php and re-linking:
brew reinstall php#7.3
brew link --overwrite php
I got an error when I tried to install xdebug in MacOS Catalina 10.15:
pecl install xdebug-3.0.1
Error:
/private/tmp/pear/install/xdebug/xdebug.c:25:10: fatal error: 'php.h' file not found
This is due to Apple decided to remove headers file in /usr/include, like you can see in other answer.
Then I added config to .bash_profile, executing these lines in console:
echo 'export PATH="/usr/local/opt/php#7.3/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.3/sbin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/php#7.3/lib"
export CPPFLAGS="-I/usr/local/opt/php#7.3/include"
source ~/.bash_profile
After that you can try to install xdebug again with pecl:
pecl install xdebug-3.0.1
Notes: Previously I have installed PHP 7.3 with "brew". You should adjust the php and xdebug version, in the above lines, adding the versions that you prefer.
I would recommend you use "brew" to install PHP, and then use the "pecl" tool that comes with the installed version of brew's PHP to install Xdebug.
you can find detailed instructions with ready to use patches on this site: https://profilingviewer.com/installing-xdebug-on-catalina.html

How to use composer with WampServer?

I am trying to use composer with my WampServer.
My path for all the files is C:\wamp64\www, but when I run composer it will install the vendor file and other stuff somewhere else.
I don't even know where and I can't change the path of where is my project.
I tried everything already and it still dose not seem to install the vendor file in my project folder.
Although it is an old post, it maybe useful as far as Wampserver exists, so the easiest fix is this:
Go to the "bin/php" folder inside you wampserver, usually at C:\wampXX\bin\php, and look for the php version used in your wampserver. You can navigate to http://localhost to find that, or click in the Wampserver icon on Windows taskbar (If yours doesn't have the version number aside, click on PHP -> Version and you'll see the checked one):
In the "bin/php" folder open the corresponding folder to your PHP
version, in my case "7.0.33" and copy this path:
Go to Windows Environment Variables, and in System Variables add that PHP's folder path you copied to Path variable (You can search on Google how to change a Path variable on your Windows version).
P.S.: In case you switch PHP version it won't work anymore, and you'll have to do that again. But now, changing for the correct PHP version folder.
After doing that, go to composer site download the windows installer.
CD into your projects root directory and run (which must contain a composer.json file):
composer install
That's it. Maybe a lot of work, but at the end it's all quite simple.
I don't use this hack any more. I think there are better tools to solve this problem, such as Laragon, LocalWP (if you develop Wordpress plugins/themes) or Devilbox (you need to install Docker to use Devilbox).
I don't know if the poster will read and vote this answer. I had this problem and solved it, and I want to share my research with other people.
TL; DR
In Windows 10, you can have Composer without producing an error in Wampserver if you install it on the Windows Subsystem for Linux (WSL) environment.
Install PHP on WSL
Then install Composer on WSL
The problem
In Windows, Composer requires to set the system variable PATH to work properly during the installation; it doesn't matter if it is installed globally using the Windows Installer or locally, following this procedure
However, inserting the executable PHP file location in PATH causes an error in Wampserver, the ERROR C:/wamp64 or PHP in path. You can see the error message if you left-click on the Wampserver icon in the notifications area of the task bar.
Although Wampserver may work as usual, it could eventually fail according to the answer to this question on the official Wampserver forum:
Wampserver does not create paths in PATH system environment variable.
Wampserver does not use PATH system environment variable.
Some content - paths to PHP or mysql versions - of the PATH system environment variable can create Wampserver malfunctions because PHP configuration files (php.ini) or MySQL (my.ini) are searched first in the paths indicated by the contents of the PATH environment variables before being searched in the Apache, PHP or MySQL folders.
That is why, with version 3.1.3, the content of the PATH environment variable is checked and you are notified if there is a problem.
If your Wamperserver installation suffers already of this error, then
follow the advice from the Wampserver forum,
back up the content of your www folder,
uninstall Wampserver,
reinstall Wampserver.
If you have Windows 10 and followed the previous steps, then you are ready to implement the solution I propose.
The solution
The only solution I found in my research was explained in this tutorial by Jeff Geerling. My answer follows this tutorial in a somewhat loose way.
My starting point
These were the settings of my PC when I began this procedure:
Windows 10 Home Edition 64-bit
WampServer Version 3.1.3 64bit, reinstalled and with no errors
Windows Subsystem for Linux (WSL) Ubuntu installed
Visual Studio Code as text editor, with WSL bash as default integrated terminal
Although Visual Studio with the WSL integrated terminal is not strictly necessary, I had it set because I intended to install and use Composer with it.
1 - Install PHP on WSL
To work correctly, Composer needs PHP but WSL does not come installed with it. So it is necessary to install PHP in this enviroment. According to this answer in AskUbuntu.com, the easiest way to install PHP on WSL is adding Ondřej Surý's PPA. In the Visual Studio Code WSL integrated terminal, type:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Test that PHP was installed correctly typing php --version. If PHP was installed correctly, the terminal will return a message like:
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
2 - Install Composer on WSL
There are two ways to do it:
The easier one: just type on the integrated terminal sudo apt-get install composer and that will be it.
The second one, and a better approach in my opinion: go to the Composer download page and get the installation code:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Warning: Do NOT copy/paste the code provided in this tutorial to install Composer. According to the Composer download page, the installation code
will change with every version of the installer.
The best practice here is to get the installation code directly from the download page.
I think this method is a better approach because, with the given code, it is possible to verify the SHA384 of the file and make sure it has not been tampered with.
If you installed Composer through the installation code from the developer website, in order to put that file into the global path on WSL, move the composer.phar file into the /user/bin/local folder with the bash command:
sudo mv composer.phar /user/bin/local/composer
If you installed Composer with the first command, this last step won't be necessary.
To check that the software was installed correctly, type composer on the integrated terminal. You should view a list of composer calling options and available commands.
Keep in mind that, to use Composer, you will need to type the commands in the WSL terminal.
Just run composer on your project folder.
Say your project path is on C:\wamp64\www\project0. So, just run composer install inside project0 folder. Composer will create vendor folder inside this project0 folder. This folder contain some folders of installed libraries.
Composer also generate a file composer.lock. This file contain information of installed libraries.
Then, when you want to use the libraries, please add this code inside your php file.
require_once "vendor/autoload.php";
This will call autoloader, so you don't need to use require_once anymore to load PHP Classess. Just call the Class using use keyword.
use Library0/Class0;
use Library1/Class1;
use Library2/Class2;
I used a different approach. I admit that it is dirty, and every time I switch PHP versions, I need to remember to update what I did, but well... it works :)
Go to C:\ProgramData\ComposerSetup\bin. There is a file there: composer.bat. This is executed every time you enter a composer install or a composer update command. Edit it with a notepad or any other text editor. You should see something like this:
#ECHO OFF
php "%~dp0composer.phar" %*
What we want to do is to give a direct path to php.exe, so let's comment out the current command and write our own:
#ECHO OFF
REM php "%~dp0composer.phar" %*
C:\wamp64\bin\php\php5.6.40\php.exe "%~dp0composer.phar" %*
Now everything works. But once you switch to another PHP version in Wampserver, you should update this file too.
By the way: a similar change can be done to make PHP sniffer or PHPUnit work too. Their bat files are in C:\Users\[your windows user]\AppData\Roaming\Composer\vendor\bin folder.
That answer is pretty bad. I have figured it out already on my own. I had to use cd commned in commend lines to get in this folder.
So after CMD i would type cd C:\wamp64\www\project0 thats proper answer to my problem.

Building XDebug For Use by MAMP?

I'm using MAMP on Mac OSX Mavericks. I'd like to install the latest XDebug, v2.2.4. Per the XDebug Wizard, I downloaded the XDebug 2.2.4 source. I have many versions of phpize installed on my system - one that is in /usr/bin/, and many others that come with MAMP. MAMP supplies the required phpize for each version of PHP it includes.
Seeking to use the correct phpize, per the XDebug Wizard instructions - http://xdebug.org/docs/faq#custom-phpize - I ran the phpize for PHP 5.5.3 via:
/Applications/MAMP/bin/php/php5.5.3/bin/phpize
..and got this output:
grep: /Applications/MAMP/bin/php/php5.5.3/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.5.3/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.5.3/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Just in case this was not an error (since it appeared that I was following XDebug Wizard directions), I then ran configure via:
./configure --with-php-config=/Applications/MAMP/bin/php/php5.5.3/bin/php-config
...and I ran:
make
...but got this error:
fatal error: 'php.h' file not found
What is the correct way to build XDebug on OSX for use by MAMP?
Thanks very much in advance to all for any thoughts or info.
I had a similar issue and it was resolved after installing XCode and the Command Line Tools for XCode. I already had XCode installed, but I recently moved over to a new machine so I had to open it back up and it updated some things. Then I opened Terminal and ran the command...
xcode-select --install
That popped up a prompt to install the command line tools which I did and it resolved my issue.
Incase anyone else stumbles across this from Google...
My issue was the wrong phpize binary was found on the path.
I was able to resolve this using the Xdebug FAQ, specifically this section: https://xdebug.org/docs/faq#custom-phpize
When Xdebug wizard asks you to run phpize, instead find and run phpize in your MAMP directory. For me, this was:
/Applications/MAMP/bin/php/php7.1.19/bin/phpize
After this, you should see an output similar to your tailored installation instructions.
Then find and run php-config in your MAMP directory (Note: this command must be run from where you have Xdebug stored on your machine). For me, this was:
./configure --with-php-config=/Applications/MAMP/bin/php/php7.1.19/bin/php-config
You'll see a bunch of output... Followed by a, "Build complete." message.
Now you can return to your tailored installation instructions (be sure to skip the next step, Run: ./configure).
Try installing autoconf using brew : brew install autoconf

Having trouble configuring sphinx search

I downloaded sphinx 0.9.9 to my ubuntu 10.4 machine.
I ran cd ~/sphinx-0.9.9 then ./configure, then make then make install.
Make install gave me errors so I ran sudo make install and then there were no errors.
I am going through the documentation. I am at 2.6. Quick Sphinx usage tour.
It says:
All the example commands below assume that you installed Sphinx in /usr/local/sphinx, so searchd can be found in /usr/local/sphinx/bin/searchd.
I do have /usr/local/sphinx but there is no bin folder in it, just etc and var.
It then also says:
there's example.sql sample data file to populate that table with a few documents for testing purposes:
$ mysql -u test < /usr/local/sphinx/etc/example.sql
but inside my /usr/local/sphinx/etc/ folder there is only one file: sphinx.conf
and according to the docs that file shouldnt event exist yet, it should be sphinx.conf.dist
I tried to install sphinx 6 months ago and gave up. I am only revisiting it now, so maybe there is a chance I screwed something up then that is giving me problems now. Is there a way to remove everything sphinx so I can try again fresh? Or does anyone have any other ideas what is going on?
You might try installing the package version of sphinx; it's slightly older, but should work as well. As far as compiling problems, you might check the SphinxSearch forum.
Looks like you have installation issue here.
The output of make command will be helpful.
I would suggest reinstalling sphinx, just delete the folder/or run sudo make uninstall, where you had installed the sphinx, and then following these steps to reinstall sphinx
Update and Grab dependencies. Run these commands in order to get the files you need to install Sphinx.
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install build-essential
sudo apt-get install libmysqlclient15-dev
Download source, Untar and prep. Here's where it gets a bit complicated. You'll need to extract the source, change into the directory and configure Sphinx. Do that with these commands.
tar xvzf sphinx-0.9.8.1.tar.gz
cd sphinx-0.9.8.1/
./configure --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql
Make and Install Sphinx
make
sudo make install

Resources