Can someone with a working Zend/PHPUnit installation tell me how PHPUnit.bat should read?
I have installed PEAR and PHPUnit, but PHPUnit.bat appears to have an error in its code.
Having worked through a few issues, I no longer get 'PHPUnit is not a recognised command' error. But if I now call "PHPUnit" in the command line nothing at all happens except the command prompt reappears. Indicating some code may have run.
I did some reading and PEAR should be calling a .bat file in 'c:\zend\zendServer\bin'. I opened this and there is a very short block of code.
if "%PHPBIN%" == "" set PHPBIN=c:\zend\zendserver\bin\php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "C:\Zend\zendServer\bin\\phpunit" %*
The final line looks incorrect, notably the double slash. I have tried various derivations such as 'bin\pear\phpunit etc', but are not sure where this should be pointing.
Can anyone with a working ZendServer/PHPUnit installation tell me how this line should read.
Also, I should also ask, is calling 'PHPunit' in the cmd line the best way to test if the package has installed correctly. Ideas appreciated. The PEAR install call suggested the install should be working fine.
UPDATE
I just created a new project through the zend framework CLI tool and got a note that PHPUnit was not found in my include_path. I have both PEAR and PHP on my include path do I need something else?
UPDATE
I found this post on a potential test Getting PHPUnit Working - Include Path not set correctly?, which provides a way to test phpUnit. I saved the suggested PHP script in my htdocs folder and tried to call it with PHPUnit. Once again no response, which seems to suggest that there is a n error in my PHPUnit.bat file.
Okay this has been a nightmare, but I think I have a solution for anyone facing the same issues.
Question One: how do I test if PHPUNit is working.
Answer: typing PHPUnit into the cmd line will give you a list of all the commands and so acts as a good test as to whether the install has worked.
Question Two: What should PHPUnit.bat look like.
The text above is correct and the extra slash in PHP.bat does not affect the output as ta.speot.is notes.
Solution to get install working:
The issue in this case related to an anomaly with Zend Server. A change to the php config file PHP.ini does not seem to get picked up by the server. It appears that Zend stores the path variables somewhere else. I noted that the changes to the include_path had not been picked up and changed it through the GUI server interface provided with the install.
PHPUnit is now working correctly.
For those struggling with an install I would add two lessons to add to the huge range of posts on the topic.
1) if you have ever had Zend on your computer. Beware an uninstall leaves trace files that can complicate later installs.
2) There is PHPUnit.ini file that gets saved in the c:\windows directory be sure to delete this before starting the install.
3) The following link is an excellent set of instructions http://www.zendexperts.com/2011/06/21/how-to-install-zend-server-ce-pear-phpunit/.
The only change I would make is when using go-pear.php to install PEAR, do not activate errors as suggested in the post, otherwise the interface does not seem to work and issues a large number of errors in the PEAR php.
Hope this helps someone save a couple of days.
Related
I'm a long time reader, but new to asking questions. Please correct me if I have somehow asked incorrectly.
Intro
We are upgrading our servers from PHP 5.4 to PHP 7.2 and one of the libraries that is not fully compatible with the new version of PHP is PHPExcel. So, we are upgrading to PHPSpreadsheet as well. A lot of our projects use PHPExcel in different ways, so if I can get the Auto Migrate tool to work, it would be a huge time save for me even if it misses some things.
The instructions to use the tool are found here:
https://phpspreadsheet.readthedocs.io/en/develop/topics/migration-from-PHPExcel/
And they simply say to use the following command after installing via Composer (which I've done):
cd /project/to/migrate/src
/project/to/migrate/vendor/phpoffice/phpspreadsheet/bin/migrate-from-phpexcel
Problem
I am able to execute the migrator fine, but it only scans files inside the "vendor/phpoffice/phpspreadsheet" directory. It does not scan any files inside my project at all.
How do I get the migration script to scan my projects files, and not it's own files?
Local Environment
Windows 10
Latest XAMPP
PHP 7.2.11
How I Am Running It
cd C:\path\to\project\that\uses\phpexcel
php vendor\phpoffice\phpspreadsheet\bin\migrate-from-phpexcel
How I have Tried To Solve So Far
Running the exact command on the instructions page (ends up running two commands, second one is an invalid command)
Moving "migrate-from-phpexcel" to my project root and running it there
Editing "migrate-from-phpexcel" after moving to project root and pointing to the Bootstrap.php file (Runs, but only inside the library itself. Same problem)
I don't know how, or from where, you ran the 2nd command but that command traversed my whole project and made what looks like appropriate conversions. I ran it from project root while I was IN my IDE (PhpStorm, using its 'Run Command' tool). I ran the same command you did, like this:
php vendor\phpoffice\phpspreadsheet\bin\migrate-from-phpexcel
After confirming "yes", I saw it traverse the directory, changing various files but skipping its OWN files.
When I tested my script, I encountered a warning about 'a non-numeric value' from one of its modules (Coordinate.php on line 312 & line 313). I did some research on the warning but couldn't find anything to address it except people blaming PHP 7.1** (I'm running 7.2.*). So I suppressed the warning and my spreadsheet was created exactly as I specified.
Here is my first statement in my 'create excel' script:
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
The only other "manual" change I had to make was changing the file format of the 'createWriter' from 'Excel2007' to 'Xlsx' -- exactly as it states in the docs. A more complicated spreadsheet may require more manual work, but probably not as much as someone above indicated.
In case it helps someone else: while updating a legacy project that was using PhpExcel v1.8.2, running rector on the codebase failed on most of the files that needed to be processed, with the error:
[ERROR] Could not process "test.php" file, due to:
"Analyze error: "PHPExcel_Writer_Exception (Unable to load PDF Rendering library) thrown while looking
for class PHPExcel_Writer_PDF_DomPDF.". Include your files in "$parameters->set(Option::AUTOLOAD_PATHS,
[...]);" in "rector.php" config.
See https://github.com/rectorphp/rector#configuration".
To get around this, I followed suggestions here: https://github.com/rectorphp/rector/issues/6418#issuecomment-882923495 and commented out lines in the PhpExcel install itself - the lines containing throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library'); in files DomPDF.php, mPDF.php, tcPDF.php in Classes/PHPExcel/Writer/PDF/
2022+ Automated Upgrade Approach
Discalimer: I wrote a tool that handles automated migration from CLI called Rector, so people don't have to upgrade PHP code manually anymore. It's free, open-source, on GitHub.
The offical migration tool only fixes class names. There are 24 more cases, that needs to be changed, lLike mentioned "'Excel2007' to 'Xlsx'".
We needed to upgrade huge PHP project and manual changes would take too much time and could stuck us for weeks. Instead, we made an upgrade set with all 25 cases, that changed code for us:
In 4 steps ↓
1. Install Rector to your PHP project
composer require rector/rector-phpoffice --dev
2. Create rector.php config
vendor/bin/rector init
3. Add the spreadsheet set:
use Rector\PHPOffice\Set\PHPOfficeSetList;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig) {
$rectorConfig->sets([PHPOfficeSetList::PHPEXCEL_TO_PHPSPREADSHEET]);
};
4. Run Rector on your code
# to see diff with no changes
vendor/bin/rector process src --dry-run
# to make changes happen
vendor/bin/rector process src
If you want to read more, we wrote a short post about it
A while ago, I successfully configured Atom to beautify my PHP using php-cs-fixer, but now I need to go through the same process on another Mac and can't remember exactly how I did it.
As a front-end dev, I'm not a PHP expert, but I understand that the Atom plugin is merely the middleman facilitating the actual fixing using php-cs-fixer, which, by default, it doesn't have access to. Once I installed the fixer, I had to add its location to my PATH variable. The confusing part is that I don't have the fixer installed via Atom (checked ~/.atom/packages) nor Homebrew (confirmed with brew list), however, the file is present in /usr/local/bin. If I move it, Atom returns the original error, so it's definitely using this file:
See https://github.com/FriendsOfPHP/PHP-CS-Fixer for program installation instructions.
Your program is properly installed if running 'which php-cs-fixer' in your Terminal returns an absolute path to the executable. If this does not work then you have not installed the program correctly and so Atom Beautify will not find the program. Atom Beautify requires that the program be found in your PATH environment variable.
Note that this is not an Atom Beautify issue if beautification does not work and the above command also does not work: this is expected behaviour, since you have not properly installed your program. Please properly setup the program and search through existing Atom Beautify issues before creating a new issue. See https://github.com/Glavin001/atom-beautify/search?q=php-cs-fixer&type=Issues for related Issues and https://github.com/Glavin001/atom-beautify/tree/master/docs for documentation. If you are still unable to resolve this issue on your own then please create a new issue and ask for help.
Hide Stack Trace
Error: Could not find 'php-cs-fixer'. The program may not be installed.
at PHPCSFixer.module.exports.Beautifier.commandNotFoundError (/Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:204:14)
at /Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:304:22
at tryCatcher (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:687:18)
at Async._drainQueue (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:148:10)
at Async.drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
at process._tickCallback (internal/process/next_tick.js:103:7)
which php-cs-fixer returns /usr/local/bin/php-cs-fixer and my PATH variable currently contains /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ourcore/.atom/packages/php-cs-fixer.
I guess my questions are, how is the fixer working if the PATH variable seems to be pointing to it in a different location, and how did it end up where it is? Does the location in my PATH matter at all, or does the Atom plugin know to look in /usr/local/bin? I just want to fully understand the entire process before repeating it.
EDIT: On further testing, I removed the Atom directory from my PATH and it didn't affect the plugin, so then I copied the file into the same directory onto the second Mac and it ran without issue, without needing to edit the PATH. Does the fixer file someone inform the OS?
Well first test "which php-cs-fixer" or "where php-cs-fixer" (depending on what os you're running) and if nothing is returned in the terminal then there actually is something wrong on the installation and the best thing to do is to manually install it.
Head to https://github.com/FriendsOfPHP/PHP-CS-Fixer and download it from there and follow the installation steps, after that it should all be good
I recently installed a cakephp with composer to learn about framework use, and trying the bookmarks tutorial, but I get stucked in the checking your installation where you have to open the command line AKA cmd, and writing bin\cake.
It replies back: the system cannot find the path specified.
I've seen some information about how to set up the path variables but I'm guessing it's for version 2+ because apparently the cakephp 3 doesn't have a LIB folder like such:
YOUR_CAKE_DIR/lib/Cake/Console/
Any ideas on how to fix this?
Thanks
best regards!
***************UPDATE**********************
well, I've finally fixed the problem, the path I used for the cakePHP 3 instalation was:
c:\xampp\htdocs\caketest\bin
so I assume that If you aren't using xampp, it should point at the end to: cakeinstallation\bin...
my problem was that I always typed bin\cake but actually all I had to do was type only:
cake
you can read more information in here
bin\cake shouldn't require any special path settings other than being in the correct directory. However, you should make sure that php-cli is on your system's PATH. Depending on how you install PHP it could be in any number of places, but if php -v doesn't output the version of PHP you installed, you'll need to find where your installer put PHP and then setup the PATH environment variable.
With your example, AFAI remember the working directory they were executing cake binary was the parent of "bin" folder, in your case "caketest". I am talking without trying it (I dont have an environment close) you should use:
c:\xampp\htdocs\caketest> "bin/cake"
Watch the quotes. I think they are the main reason of that "the system cannot find the path specified."
I am supossing you are under windows (I saw xampp written in your post) and probably the xampp installation has already added the php folder in the PATH environment variable.
I'm trying to set up a FuelPHP app, and I've run into a puzzling problem. Every time the app tries to connect to the database, I get the following error:
Fuel\Core\Database_Exception [ Error ]: invalid data source name
I've set FUEL_ENV to "stage" in Apache's VirtalHost configuration and the database credentials in fuel/app/config/staging/db.php seem to be correct: I can log in to PhpMyAdmin using the same username and password. I'm stumped as to what else to try - any advice would be much appreciated.
In case it helps, I'm using FuelPHP 1.4 on an Amazon EC2 instance running Ubuntu 12.04 LTS on which I've installed MySQL and PHP via apt-get. I have another app (on another instance) running an older version of FuelPHP (1.2.1) which runs with no problems.
Incidentally, this question is probably closely related to this one, but I'm asking it as a separate question because the problem I'm having is not limited to the command line.
Ok, this has taken far too long to get to the bottom of, but it turns out to be simple to fix: for some reason, in FuelPHP 1.4 the stage environment's config directory is called staging (in previous versions it was stage).
I don't know whether this is a directory naming mistake, or whether this is a new name and something somewhere in FuelPHP hasn't been updated to use it, but I found changing the directory's name to 'stage' fixed the problem.
I had the same issue when running unit tests with FuelPHP's oil utility. If you're running into this issue, it most likely is a configuration issue.
To debug, somewhere in the code that isn't working put something like the following to see what environment FuelPHP is trying to use:
<?php
echo "env: " . Fuel::$env;
exit;
In my case, it showed it was trying to use the 'Test' environment. Since I didn't have a 'test' folder in my app's config folder, it was failing.
In most versions of FuelPHP, however you have the Fuel::$env set in your .htaccess file will work throughout all versions of FuelPHP. However in older versions, you may run into this issue.
You can either edit the bootstrap.php file and manually set the FuelPHP environment how you want, or setup the environment that it's trying to use.
Apache web server: SetEnv FUEL_ENV DEVELOPMENT Hope this helps someone
For those of you who none of this worked make sure of two things
there are multiple db.php files /fuel/app/config/development/db.php. check environment as #Chad Hutchins mentioned and double check the username and password is correct
Make sure /var/mysql/mysql.sock exists. In my case I was using /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock so i needed to create a symlink. Followed the instructions here
Hope that helps someone
I have Windows 7 and WAMP localhost on drive D:. I installed Symfony2 correctly. When I open http://127.0.0.1/Symfony/web/config.php I can see the Welcome! message. But in the tutorial "Creating Pages in Symfony2" when I want to create a bundle by this command:
php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml
This message appears:
"php is not recognized as an internal or external command oprable program or batch file"
I don't know what I should do.
You are receiving that error because PHP is not in your system PATH. Check out this quick tutorial on installing PHP on Windows. Take note of Step 4 which is the installation step that should fix your problem.
Since you're using WampServer, the path you have to add to PATH will be something like this:
"C:\Program Files (x86)\Wamp\bin\php5.3.10"
This is only an example, change the path to the actual path to PHP on your system. If the path has spaces in it (like Program Files (x86) does) it is helpful to always surround it with quotes (").
Update: I ended up getting on a screen sharing program with #reza and discovered he had accidentally set his PATH variable to D:\php\wamp\bin\php\php5.3.10\php.exe rather than D:\php\wamp\bin\php\php5.3.10. Fixing this solved the problem.