Home Download Buy Blog Forum Support

php syntax checker, php build

php syntax checker, php build

Postby roman on Fri Dec 04, 2009 3:46 pm

Is in Sublime editor php syntax checker? can this function be done somehow? Can it be done with setting up new build option and if so, how to do that?

Thanks!
roman
 
Posts: 6
Joined: Fri Dec 04, 2009 3:43 pm

Re: php syntax checker, php build

Postby EJ12N on Fri Dec 04, 2009 5:00 pm

I'm 99.9% sure it can be done via a plugin, as long as php is installed in your system, a quick php -l or something would take care of it... now it would be the bomb if we could manipulate the squiggly red lines you get when a word is mispelled thru the API so we can mark the error like zend studio does but I'm afraid that's not possible right now!

So yes It can be done (I believe so), it's been on my TODO list for a while :D maybe I should start coding it >.<

I haven't messed around with build files so it could work with that too :D
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: php syntax checker, php build

Postby roman on Fri Dec 04, 2009 6:10 pm

Would be cool if Sublime would make check before save, so it will prevent you from saving script with mistakes.
roman
 
Posts: 6
Joined: Fri Dec 04, 2009 3:43 pm

Re: php syntax checker, php build

Postby EJ12N on Mon Dec 07, 2009 5:02 pm

roman wrote:Would be cool if Sublime would make check before save, so it will prevent you from saving script with mistakes.

I Agree, but I dont think build mechanism has "build pre save" I know it has "build on save"
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: php syntax checker, php build

Postby EJ12N on Mon Dec 07, 2009 5:40 pm

Here's the sublime-build file for PHP
Code: Select all
build C:\xampplite\php\php.exe -l "$File"
lineNumberRegex ^.*in (.+?) on line ([0-9]*)$


Obviously edit/replace path to php.exe to your specific path. OR you can add php to your PATH enviromental variable and just do a php -l
That should work, now if we get an API to control "spelling" squiggly lines so we can underline the bad lines (or if the build does this by default!) and we get a buildOnPreSave, I think we are good to go! :D

We can even make it syntax check as we type hooking in the onModified event... and put a timeout so it checks every 5 secs or 10s whatever! a la zend studio :)
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: php syntax checker, php build

Postby roman on Wed Dec 23, 2009 8:08 pm

Thanks!

Actually with small change in code in first line you can run php scripts directly in console, change "-l" to "-a". for more information chech php documentation at http://php.net/manual/en/features.commandline.php

final code for running php scripts:
Code: Select all
build "\xampplite\php\php" -a "$File"
showWhenFinished true


this can be heplfull when you want to check and run small scripts, or when you just want to try behaviour of particular function(s)
roman
 
Posts: 6
Joined: Fri Dec 04, 2009 3:43 pm

Re: php syntax checker, php build

Postby EJ12N on Tue Jan 05, 2010 5:37 pm

roman wrote:Thanks!

Actually with small change in code in first line you can run php scripts directly in console, change "-l" to "-a". for more information chech php documentation at http://php.net/manual/en/features.commandline.php

final code for running php scripts:
Code: Select all
build "\xampplite\php\php" -a "$File"
showWhenFinished true


this can be heplfull when you want to check and run small scripts, or when you just want to try behaviour of particular function(s)


True that! thx for the addition :)
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: php syntax checker, php build

Postby jasondavis on Thu Sep 01, 2011 12:58 am

I am wanting to run the example code

Code: Select all
build "\xampplite\php\php" -a "$File"
showWhenFinished true


I went to
Tools -> Build System -> New Build System

which creates a file with

Code: Select all
{
   "cmd": ["make"]
}


I saved it as php.sublime-build

It now shows up in Tools -> Build System as "php" so I select it.

I just need to know what I should save in this file, I tried...

Code: Select all
build "\xampplite\php\php" -a "$File"
showWhenFinished true


But that gives errors when I try to build any file...please help
jasondavis
 
Posts: 23
Joined: Thu Sep 01, 2011 12:52 am

Re: php syntax checker, php build

Postby aparajita on Thu Sep 01, 2011 3:09 am

roman wrote:Is in Sublime editor php syntax checker? can this function be done somehow?


The SublimeLinter plugin does php syntax checking.

https://github.com/Kronuz/SublimeLinter, or install with the package_control plugin.
aparajita
 
Posts: 177
Joined: Sun Jul 24, 2011 10:42 pm

Re: php syntax checker, php build

Postby NiPh on Sat Oct 15, 2011 8:12 pm

jasondavis wrote:I am wanting to run the example code
But that gives errors when I try to build any file...please help


Maybe it's too old theme, but i beleve i'll help someone )
So the code is
Code: Select all
{
    "cmd": ["C:\\Program Files (x86)\\Zend\\ZendServer\\bin\\php.exe", "-a", "$file"],
    "selector": "source.php"
}
NiPh
 
Posts: 2
Joined: Sat Oct 15, 2011 7:55 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot] and 17 guests