Does BBE support Syntax and Formatting for PHP code

1,744 views
Skip to first unread message

Robert A. Rosenberg

unread,
Jun 13, 2012, 11:23:10 PM6/13/12
to bbe...@googlegroups.com
The subject says it all. Is there support for being able to format
PHP code (either Pure PHP or intermixed with HTML) as I can do for
HTML via the Format Options of Markup->Utilities. The same question
for doing a Syntax Check of the PHP code.

Thank You.

Alex Satrapa

unread,
Jun 14, 2012, 12:35:31 AM6/14/12
to bbe...@googlegroups.com
While BBEdit doesn't have any tidying/syntax checking for PHP (or Perl, or Python or …) there is a phptidy script on the intertubes, and there is discussion of how to use it with TextWrangler (and I assume, by extension, with BBEdit) here: http://magp.ie/2011/01/10/tidy-and-format-your-php-and-meet-wordpress-standards-on-coda-and-textwrangler/

HTH
HAND

Robert A. Rosenberg

unread,
Jun 14, 2012, 4:39:59 PM6/14/12
to bbe...@googlegroups.com
At 14:35 +1000 on 06/14/2012, Alex Satrapa wrote about Re: Does BBE
support Syntax and Formatting for PHP code:

>While BBEdit doesn't have any tidying/syntax checking for PHP (or
>Perl, or Python or �) there is a phptidy script on the intertubes,
>and there is discussion of how to use it with TextWrangler (and I
>assume, by extension, with BBEdit) here:
>http://magp.ie/2011/01/10/tidy-and-format-your-php-and-meet-wordpress-standards-on-coda-and-textwrangler/

Thanks. I installed it and it seems to meet my formatting needs. I
assume that it handles the syntax checking at the same time although
I would rather go with a syntax checker as opposed to a formatter
which fixes what it thinks you are trying to do as opposed to just
flagging errors for inspection and correction. I have been burned by
using a tidy type fixer which made the wrong correction from what I
wanted (ie: A syntax check spotted an error in nesting that needed to
be hand corrected).

>
>HTH
>HAND
>
>On 14/06/2012, at 13:23 , Robert A. Rosenberg wrote:
>
>> The subject says it all. Is there support for being able to format
>>PHP code (either Pure PHP or intermixed with HTML) as I can do for
>>HTML via the Format Options of Markup->Utilities. The same question
>>for doing a Syntax Check of the PHP code.
>
>
>--
>You received this message because you are subscribed to the
>"BBEdit Talk" discussion group on Google Groups.
>To post to this group, send email to bbe...@googlegroups.com
>To unsubscribe from this group, send email to
>bbedit+un...@googlegroups.com
>For more options, visit this group at
><http://groups.google.com/group/bbedit?hl=en>
>If you have a feature request or would like to report a problem,
>please email "sup...@barebones.com" rather than posting to the group.
>Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>


Nello Lucchesi

unread,
Jul 1, 2012, 9:33:26 PM7/1/12
to bbe...@googlegroups.com
On Thu, Jun 14, 2012 at 3:39 PM, Robert A. Rosenberg <rar...@banet.net> wrote:
> At 14:35 +1000 on 06/14/2012, Alex Satrapa wrote about Re: Does BBE support
> Syntax and Formatting for PHP code:
>
>> While BBEdit doesn't have any tidying/syntax checking for PHP (or Perl, or
>> Python or Š) there is a phptidy script on the intertubes, and there is
>> discussion of how to use it with TextWrangler (and I assume, by extension,
>> with BBEdit) here:
>> http://magp.ie/2011/01/10/tidy-and-format-your-php-and-meet-wordpress-standards-on-coda-and-textwrangler/
>
>
> Thanks. I installed it and it seems to meet my formatting needs. I assume
> that it handles the syntax checking at the same time although I would rather
> go with a syntax checker as opposed to a formatter which fixes what it
> thinks you are trying to do as opposed to just flagging errors for
> inspection and correction. I have been burned by using a tidy type fixer
> which made the wrong correction from what I wanted (ie: A syntax check
> spotted an error in nesting that needed to be hand corrected).
>

Robert:

Now that you've used it a while, are you still happy with it?

- nello

Dorian Jepsen

unread,
Sep 17, 2013, 9:30:11 PM9/17/13
to bbe...@googlegroups.com
Thank you, AG. Your instructions were the solution I needed.


dwrh

unread,
Sep 18, 2013, 8:12:22 AM9/18/13
to bbe...@googlegroups.com
Thanks, this looks very useful Andy, but I get:
===
/Library/Application Support/BBEdit/Text Filters/Tidy PHP.sh: line 2: orig: Permission denied
/Library/Application Support/BBEdit/Text Filters/Tidy PHP.sh: line 3: output: Permission denied
cat: orig: No such file or directory
rm: orig: No such file or directory
rm: output: No such file or directory
===
I have put -rwxrwxrwx on this file, but to no avail...
Any guidance?

Cheers,
David

On Friday, September 28, 2012 8:50:13 PM UTC-7, Andy Guzman wrote:
Mophilly -

I know you posted over a month ago, but I was just trying to sort out the same thing so I'll leave a note here of what I did in case you still need it or anyone else comes across this post. The solution is actually spread across a few of the comments in the post that was linked.

1. Download and uncompress the phptidy library as linked in that post. There also appears to be an updated but more Wordpress specific version here: https://github.com/scribu/wp-phptidy
2. Navigate to your BBEdit "Application Support" directory (either in ~/Library or ~/Dropbox depending on your preference).
3. Copy the Tidy PHP.sh file to the "Text Filters" folder.
4. Copy the phptidy.php file to the "Unix Support" folder.
5. Open up the Tidy PHP.sh file in BBEdit and replace the content with the following code:

#!/bin/sh
cat /dev/stdin >orig
../Unix\ Support/phptidy.php source orig > output
if [[ -s output ]]; then
cat output;
else
cat orig;
fi
rm orig;
rm output;
 
5a. If you decided to grab the wp-phptidy you'll want to change line 3 slightly
6. Now try to run the text filter within BBEdit from the Text>Apply Text Filter>Tidy PHP menu item.
7. Success! (hopefully)

There also may be a potential issue if you're running Mountain Lion - but I'm not 100% sure. I know that a lot of previously built in command line tools seemed to disappear in 10.8 but are re-installed with Xcode. Not sure if anything for these steps could be amongst the missing tools, but something to consider if you're troubleshooting.

On Sunday, August 19, 2012 10:49:34 AM UTC-7, Mophilly wrote:
I have not tried to add a Text Filter to BBEdit before.

I am having a bit of trouble getting this to work with BBEdit 10.1.2. I followed the instructions at post referenced above, "Tidy and format your PHP and meet WordPress standards on Coda and TextWrangler".

First try I put the wp-phptidy.php file in /usr/bin/, and "Tidy PHP.sh" in Text Filters. I got an error 32 trying to "apply text filter". Then I put both files into the Text Filters directory. I got an error 32 trying to "apply text filter" with Tidy PHP.sh or wp-phptidy.php.

In both cases applied  chmod to the php file, and relaunched BBEdit before attempting to invoke the script.

Can someone point me to a "how to" or similar?

Rick Yentzer

unread,
Oct 15, 2013, 8:39:23 AM10/15/13
to bbe...@googlegroups.com
Were you able to get this to work, or are you still having trouble?

Andy Guzman

unread,
Nov 1, 2013, 1:51:08 PM11/1/13
to bbe...@googlegroups.com
Sorry I didn't see this last month - I don't check here often.

I think the issue is permissions on the /Library/Application Support/BBEdit/Unix Support folder. The script writes a temporary file there alongside phptidy.php.

I have my BBEdit support files all under Dropbox, so I assume the permissions on the folders might be a bit different than whatever the default behavior is.


Actually... looking at your error again - did you happen to cut something out of the path before you posted here? I think it should be /Users/(your username)/Library/Application Support/BBEdit/(etc). /Library/Application Support is the system level Library folder which you probably don't have permission to write to by default. Make sure to use/put your scripts the Library folder within your user account.

StBb

unread,
Nov 21, 2013, 6:49:40 PM11/21/13
to bbe...@googlegroups.com, rar...@banet.net
As long as just php syntax checking is needed / wanted for me the ultimative solution still is


Despite being almost 10 years old by now it simply works, is reliable and helpful. I use it every day. Bind it to an easy shortcut (F7 is mine, just honoring SciTE), make it a habit to hit F7 before cmd-s, and on you go.

There is a daughter project for JavaScript, if one is doing such heavily:


It's not as picky as a true jslint (http://www.jslint.com) but for common real world cases that may be rather welcome. I have it on ctrl-F7 and use it often. (and it should anyway be easy to adapt to the "true jslint" - never had a need to undertake that little effort so far, anyway)

regards,
--stefan

isao

unread,
Feb 13, 2014, 4:46:11 PM2/13/14
to bbe...@googlegroups.com, rar...@banet.net
I have a PHP linting applescript that I had used for many years as well. Rather than displaying a dialog, all lint/syntax errors are displayed in a BBEdit Result Browser. Still works. Posted the source here just now:

    https://gist.github.com/isao/8984460

Also, FWIW, I made jshint and jslint versions too, those these require node.js/npm.


Cheers,

Isao

Marcianne O'Day

unread,
Jul 24, 2014, 10:24:32 AM7/24/14
to bbe...@googlegroups.com
Another thanks here! 
Reply all
Reply to author
Forward
0 new messages