phpfmt_stable icon indicating copy to clipboard operation
phpfmt_stable copied to clipboard

Stuck formating with php 7.4 from xampp stack

Open arcanisgk opened this issue 4 years ago • 6 comments

i have updated version of xampp Stack in my Dev PC old version is php 7.2 and actual php 7.4.6 version when i try to formating with php 7.4.6 from xampp stack Sublime Text 3 is Stuck i cant find any information in my PC to check around this stuck.

{
	"enable_auto_align": true,
	"format_on_save": false,
	"indent_with_space": 4,
	"php_bin": "C:/xampp/php/php.exe",
	"psr1": false,
	"psr2": false,
	"version": 4
}

arcanisgk avatar May 21 '20 18:05 arcanisgk

Same here, I also have the same problem after installing php 7.4.6. Solution for a while installing a standalone PHP 7.2 in a separate directory and ensure php_bin parameter is pointed to this standalone installation.

yoriadiatma avatar May 28 '20 14:05 yoriadiatma

I can't too make it work properly when formatting

...
public array $ar = [];
...

in php 7.4. I get this with psr2 = true

arrayprotected $fillable = [

so it breaks the code

driade avatar Jun 12 '20 22:06 driade

I can't too make it work properly when formatting

...
public array $ar = [];
...

in php 7.4. I get this with psr2 = true

arrayprotected $fillable = [

so it breaks the code

For if someones gets here with the same problem, add

"excludes": [
        "PSR2ModifierVisibilityStaticOrder"
],

to your phpfmt.sublime-settings and you're done. This rule is the one that will make you get into this error.

driade avatar Jun 12 '20 23:06 driade

not work for me

arcanisgk avatar Jun 13 '20 13:06 arcanisgk

i solve it downloading older version of php from:

https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/7.2.31/

xampp-portable-windows-x64-7.2.31-1-VC15.zip

Extranting only the php folder and renaming Like this:

image

and configure like this:

{
	"enable_auto_align": true,
	"format_on_save": false,
	"indent_with_space": 4,
	"php_bin": "C:/xampp/php72/php.exe",
	"psr0": true,
	"psr1": false,
	"psr2": true,
	"psr4": true,
	"version": 4
}

image

And if you whant to run diferent Version of php; my recomendation:

you must edit your apache httpd-xampp.conf; and add this to the end for every non-pre-installed version

ScriptAlias /php72 "C:/xampp/php72"
Action application/x-httpd-php72-cgi /php72/php-cgi.exe
<Directory "C:/xampp/php72">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
        Require all granted
    </Files>
</Directory>

Additional you must create Virtual Host, must edit httpd-vhosts.conf; and add at the end the new folder or path of the host; and the right settings:

<VirtualHost *:80>
	ServerAdmin [email protected]
	DocumentRoot "\xampp\htdocs\new\path"
	ServerName test.url
	ServerAlias *.test.url
	<Directory "\xampp\htdocs\new\path">
		Options Indexes	
		AllowOverride All
		Require all granted
		Allow from all
	</Directory>
	<FilesMatch "\.php$">
        SetHandler application/x-httpd-php72-cgi
    </FilesMatch>
</VirtualHost>

Remember that if you do not have a registered domain you will also have to edit the file host and add it if it is local.

C:\Windows\System32\drivers\etc

127.0.0.1	www.test.url
127.0.0.1	test.url

I am writing code in 3 different projects: By default php 7.4.6 is used without having to add SetHandler configurations on virtual host and for the other two that if needed use php 5.6.36 and 7.2.31

arcanisgk avatar Jun 19 '20 17:06 arcanisgk

I had an issue with phpfmt removing my PHP 7.4 typed properties visibility modifiers.

Before formatting it was private Collection $topLevelCategories;. After: Collection $topLevelCategories; which is definitely not a correct PHP code. Thanks to @driade ansver above the fix he gave worked great in my case too.

Namely add the following setting to your phpfmt.sublime-settings (Menu->Preferences->Package settings->phpfmt->Settings-User):

"excludes": [
        "PSR2ModifierVisibilityStaticOrder"
],

I could not find any dolution re this typed properties phpfmt issue so I just keep it here.

WhereJuly avatar Feb 13 '21 11:02 WhereJuly