CakePHP 3.10 -> 4.x Upgrade - Rector won't start - php

I am in the process of upgrading a site from CakePHP 3.10.0 to CakePHP 4.x using the 4.x Upgrade Guide. I have been successful up until the point where you need to run the following commands:
bin/cake upgrade rector --rules phpunit80 <path/to/app/tests>
bin/cake upgrade rector --rules cakephp40 <path/to/app/src>
I skipped the first command as I do not do unit testing (yet!). When I run the second command, it just hangs. There is no output at all from this command. I have let it sit for hours but it does nothing. I added -v to the command and finally got some output but it still hangs:
$ bin/cake upgrade rector --rules cakephp40 ../vintage-lib/src -v
Detecting autoload file for /mnt/d/Programming/PHP/vintage-lib/src
-> Checking /mnt/d/Programming/PHP/vintage-lib/src/vendor/autoload.php
-> Checking /mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php
-> Found /mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php
Running /mnt/d/Programming/PHP/upgrade/vendor/bin/rector process --autoload-file='/mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php' --config='/mnt/d/Programming/PHP/upgrade/config/rector/cakephp40.php' --working-dir='/mnt/d/Programming/PHP/vintage-lib/src' '/mnt/d/Programming/PHP/vintage-lib/src'
I have tried running this in Windows, WSL and even in a Linux VM - the result remains the same which makes me believe it is something with my code or a config file. I tried to run the command on each of my plugins but I get the same result.
I have also run and fixed all errors and warnings from codesniffer but it makes no difference.
I am at a loss as I don't know where to check next. Any assistance would be greatly appreciated.

I undertook an upgrade from 3.4 to 4.0 following the migration guide to a T, going through each minor upgrade and I still had the same issue with rector hanging.
Solution was, there is an Out of the Box PagesController that has been changed at some point between 3.4 and 3.10. I had to replace it with the version from the skeleton app (https://github.com/cakephp/app/blob/3.x/src/Controller/PagesController.php) in order for rector to pass.
If that's not your problem, try running rector one directory at a time to identify the problematic file. You can find the directory listing like:
$ find /path/to/app/src/ -type d

Related

Symfony "no PHP binaries detected"

Ive been just starting to learn Symfony PHP framework, and Ive run into some problems with its configuration.
When trying to create a new project with command line like so:
symfony new --full my_project
I kept getting a simple error message:
no PHP binaries detected
and no files were created in the current folder. I searched on the net, and found out that Symfony apparently isnt able to find the location of my php.exe, despite it already being set in my system variables. And there was no information about how to properly configure this in Symfony.
How do I fix this error?
Turns out Symfony already contains functions to autodetect installed PHP versions from system variables. The command to fix the Symfony configuration is this:
symfony local:php:refresh
My next attempt to create a new project work fine after that.
Also, I suspect this error was the result of me installing PHP files after installing Symfony.
symfony local:php:refresh
doesn't always work. If your php is not in [/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /usr/games /usr/local/games /snap/bin] and a few other locations (check with symfony local:php:list -vvv) then symfony won't find it.
I compiled my own PHP from source and installed versions 7.4.20 and 8.0.7 in /home/username/php/7.4 and /home/username/php/8.0. If I want to use my PHP 8.0.7, then I have to make a symlink because updating the $PATH doesn't help.
sudo ln -s /home/username/php/8.0/bin/php /usr/local/bin/php
This works and symfony finds it.
Follow below steps:
Step 1: download & Install xampp in your system
Step 2: open the xampp folder.
find php folder and hit enter
Step 3: copy the path and paste in your system environment
Step 4 : run
php -v
you are good to go!

Laravel 5 phpunit is not running tests

I'm been at this for days with no success. Running Laravel 5.1.
As I understand according to the Laravel doc.
An ExampleTest.php file is provided in the tests directory. After installing a new Laravel application, simply run phpunit on the command line to run your tests.
Ok so after running phpunit I found it is not globally installed and is located in vendor/bin/phpunit. Proceeding to run vendor/bin/phpunit gives me a screen with all the command options for phpunit. Its does not actually run any tests.
I searched more and came across a post that mentioned it could be a symlink issue. I followed the instructions in the post with no success. From memory I installed Laravel from composer so the symlink should not be an issue anyway.
These instructions involved deleting various files. I did notice that composer was pulling files from its cache when updating. So I cleared its cache and followed the process again. Still no success.
What are the tests not running? I'm at my wits end. Especially since its is supposed to run easily out the box.
In the end I was not calling the bat file correctly. I was running
C:\localhost\myProject\vendor\bin> phpunit
Instead I needed to run
C:\localhost\myproject> call vendor\bin\phpunit
Hence it now is referencing the phpunit.xml file with the test location information.
You need to install phpunit globally:
composer global require phpunit/phpunit
Then you can run phpunit from your project root.
You could just run the phpunit that comes with the project, just go to your project root and run ./vendor/bin/phpunit, that way the tests will execute the way they should be and you could get feedback in case it fails.
For some reason I haven't figure out yet if you install phpunit globally in your computer you won't get feedback of your tests.

Netbeans 8.0.1 with PHPUnit and Skeleton generator

I have installed Netbeans together with PHPUnit and phpunit-skeleton-generator from homebrew. I can generate a testfile from the terminal by running phpunit-skelgen --test -- "UrlDecoder" classes/UrlDecoder.class.php, however Netbeans refuses when I right-click the file, select tools > Create tests.
This is the error I get:
And this is the output from the log:
"/usr/local/opt/php55/bin/php" "/usr/local/bin/phpunit-skelgen" "--ansi" "generate-test" "--bootstrap=/Users/paulp/Sites/fortv/tests/bootstrap.php" "UrlDecoder" "/Users/paulp/Sites/fortv/classes/UrlDecoder.class.php" "UrlDecoderTest" "/Users/paulp/Sites/fortv/tests/classes/UrlDecoder.classTest.php"
/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/Cellar/phpunit-skeleton-generator/1.2.1/libexec/phpunit-skelgen-1.2.1.phar $*
Done.
Most tutorials and help I find online are for Netbeans 7.x, which makes things harder. I have tried with different bootstrap files and xml files, but no different result. The Output tells me nothing, and nothing happens.
I have googled this for a bit, but found nothing similar to my problem.
The only thing I notice is the --ansi part, which the skeleton generator documentation doesn't seem to offer.
My question: How can I get Netbeans to generate tests using phpunit skeleton generator?
I've installed phpunit on my Mac manually following the manual's instructions (it is pretty easy so you don't need brew script).
Then in Netbeans (8.0.2) preferences (PHP->Frameworks&Tools->PHPUnit) I have set up paths to sctipts.
In the project properties phpunit should be switched on (I know that's obvious). And then Tools->Create tests works just out-of-the-box. :)
However my first experience with phpunit installation was not so funny. So I can understand that users could be frustrated at the begining. It was because I have expected full automation through plugin installation and such things which not worked. That's why I describe full process (phpunit+netbeans on osx)on my [blog][1].

How to install ZendFramework 2 in windows 7 XAMPP?

There are many documentation about how to install Zend Framework 2. But they are hard to understand. I've tried lot of guidance in the web. But still I couldn't install ZF2.
This might be a duplicate question. But I went through most of them and ended up with no success.
Can any one please give me the simple step by step installation guidance?
I'm using XAMPP on windows 7
Thanks a lot
EDIT: I'm getting this error
once you download skeleton application from Github you have run following command from command prompt
cd ZendSkeletonApplication
php composer.phar self-update
php composer.phar install
make sure you have php version greater than 5.3.3
php command not run directly in command prompt if path variable is not set
to check path variable set or not type php -v if command not recognized than please set environmental variable.

Unable to update Laravel 4 with Composer (Update: bug?)

Today, I pulled down the laravel/laravel repository from Github. I then ran php composer.phar install (as I normally would on my system, with a command window in the project directory). However, when I ran php composer.phar update, I received this error:
Everything installed just fine, and Laravel works as it should.
Any ideas what could be causing this issue?
Edit 1
artisan exists in the root of the project, but it throws an exception when I attempt to run php artisan optimize:
Side Note 1
If I try the alternative method (quicker) of installing Laravel (php composer.phar create-project laravel/laravel), I get the following:
Edit 2
Upon installation, I also get the same error, where it claims it cannot find artisan. Therefore, the installation does not fully complete. I believe that it is stopping when it wants to compile classes (or something to that effect), and then write bootstrap/compiled.php. That file doesn't exist.
Here's the snap from the install:
Edit 3
It seems that Composer is looking for artisan in the drive root (C:\). Why is it doing this? Even if I specify -d on the update, it throws the error. (I picked this up from a hunch - simply copied artisan to the root of the drive and it found it - albeit, it obviously did not run...)
Solution Found:
Composer makes calls to php artisan <command> (as per the instruction in composer.json > scripts), but it does not see what directory it is running from (perhaps because it is an external command?).
So, I solved my initial problem by using an absolute path to artisan in composer.json.
Everything is working now. I just wish I knew how to get Composer to know that it is running from C:\LocalServer\lab\laravel, and not just C:\.
As i can see, your artisan file is missing. Can you post the exact steps on how you install it ?
Also, please follow http://laravel.com/docs/installation and http://niallobrien.me/2013/03/installing-and-updating-laravel-4/
I had this problem today too. My laravel folder inside the vendor was deleted after composer update. I ran composer install again and problem resolved.

Categories