Sublime Text 3 - PHP Build System

Struggling with this quite a bit.

Trying to add a PHP build system is what I have:

{
    "cmd" : ["php", "$file"],
    "file_regex": "php$",
    "selector"  : "source.php"
}

      

Now, creating a file named test.php

that contains: <?php echo "Hello, World!"; ?>

throws this error:

[WinError 2] The system cannot find the file specified
[cmd: ['php', 'D:\\www\\sandbox\\php\\test.php']]
[dir: D:\www\sandbox\php]

      

PHP is definitely on mine PATH

and works php test.php

via the command line.

Can anyone shed some light?

+3


source to share


4 answers


PHP.sublime assemblies:

{
    "cmd": ["C:\\php\\php.exe", "$file"],
    "file_regex": "php$",
    "selector": "source.php"
}

      



Redirect in this single path to php.exe ("C: \ php \ php.exe"). After saving press F7 on your php code. Hope this helps someone.

+10


source


You just need to change the path to your php.exe . For example, I am using wampserver, so my php.exe is under C:\wamp64\bin\php\php5.6.16

, thus the solution is:

{
    "cmd": ["C:\\wamp64\\bin\\php\\php5.6.16\\php.exe", "$file"],
    "file_regex": "php$",
    "selector": "source.php"
}

      



It worked for me, good luck :)

+2


source


This is the build system I am using to run php script in terminal / browser.

{
"shell_cmd": "php -l \"$file\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "embedding.php",
"variants": 
[
    {
        "shell_cmd": "gnome-terminal -- bash -c \"php $file;echo;echo Press enter to exit...;read\"", 
        "name": "Run(terminal)"
    },
    {
        "shell_cmd":"firefox \"localhost/$file_base_name.php\"", 
        "name":"Run on Server"  
    }
]

      

}

0


source


Modified code:

{ 
   "cmd": ["C:\\xampp\\php\\php.exe", "$file"],
   "file_regex": "*",
   "selector": "source.php"
}

      

-1


source







All Articles