PHP build system error in sublime text 3

3.8k views Asked by At

System configuration:

Ubuntu 14.04 (64 bit) + Xampp installed (/opt/lampp) + Sublime text 3 (Build 3065 )

I am trying to create PHP Build System inside sublime text 3 with help of This interesting post but failed to do do. Please see my work and issue so far

Create new build via Tools > Build System > New Build System ... and save as

php.sublime-build

{
    "cmd": ["php", "-l", "$file"],
    "file_regex": "php$",
    "selector": "source.php",
    "working_dir": "${project_path:${folder:${file_path}}}"
}

Now When press Ctrl + B or F7 on a .php file it gives below error

[Errno 2] No such file or directory: 'php' 
[cmd: ['php', '-l', '/opt/lampp/htdocs/wish/make.php']] 
[dir: /opt/lampp/htdocs/chrome] 
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]  
[Finished]

It seems php path issue , so added php path in that file

"cmd": ["/opt/lampp/bin/php", "-l", "$file"]

now Ctrl+B gives no error in the console BUT gives info on status bar : file build finished with 1 error (see the image below )

and it does not show the output in Sublime Text window which was expected behavior of this build system

what is the wrong here, Please correct me.

screenshot

Reference : Sublime text Build system

1

There are 1 answers

0
xkeshav On BEST ANSWER

I solved finally. below are the steps

  1. Install php5-cli

    sudo apt-get install php5-cli
    

    While installing , it will gives the php path something like this

    update-alternatives: using /usr/bin/php5 to provide /usr/bin/php (php) in auto mode

  2. Check the command line php with a .php file on terminal (Ctrl+Alt+T)

    :~$ /usr/bin/php /opt/lampp/htdocs/parixan/arr.php 
    

    it executed fine

  3. edit /home/keshav/.config/sublime-text-3/Packages/User/php.build_system

    changed the path and remove "-l" which was second argument

    "cmd": ["/usr/bin/php", "$file"]
    
  4. Restart the sublime text and press Ctrl+B on a opened .php and output of that file returns in Sublime window.( expected behavior ).

Hope it help someone. :)