Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option for PHP Beautifier filters #107

Closed
joeguilmette opened this issue Sep 28, 2014 · 9 comments
Closed

Add config option for PHP Beautifier filters #107

joeguilmette opened this issue Sep 28, 2014 · 9 comments

Comments

@joeguilmette
Copy link

So, my journey began when I wanted to easily beautify a particularly nasty PHP array. "I'll just use this neat looking package, Atom Beautify!" I said to myself. Turns out it requires PHP Beautifier. No problem, I'll just install it. Well, the package on the Atom package manager 404'd, so I went ahead to manually install it. And then I needed Pear. And then I needed to add it's include path to php.ini, but actually there is no php.ini so I needed to copy it over from wherever it was hiding (don't ask because I really have no idea where it was). Then I was finally able to add the include_path for Pear into php.ini, but only after googling around to figure out how nano works so as to avoid borking things further. I'm not willing to admit how many hours it took to get there.

Imagine my despair when php_beautifier, used through Atom Beautify, simply compressed the entire array into a single line. Not ideal!

Upon further research, I have found that there are filters out there that will help, but...

my real question is,

tl;dr: How do I use php_beautify filters with Atom Beautify?

@Glavin001
Copy link
Owner

I am unfamiliar with filters for php_beautifier, since I rarely write PHP. I found http://beautifyphp.sourceforge.net/docs/PHP_Beautifier/Filter/tutorial_Filter.create.pkg.html hopefully that helps. If there is anything that I can help with from Atom Beautify's perspective, such as adding configuration option to support filters however that works, please let me know.

@Glavin001
Copy link
Owner

If you could document in a little more detail your steps for PHP_beautifier installation, I think it would be very valuable for others who could be having the same problems with installation. It is unfortunate that the installation process for php_beautifier is so poor.

@joeguilmette
Copy link
Author

Well, it was actually simple. I just used Pear and ran pear install php_beautifier. The horrible part was configuring pear and adding it's path to php.ini, and that was only horrible because for some reason my php.ini was not where it should be.

I'll investigate adding filters and get back to you tomorrow.

Thanks for being so responsive!

On Sep 28, 2014, at 7:10 PM, Glavin Wiechert notifications@github.com wrote:

If you could document in a little more detail your steps for PHP_beautifier installation, I think it would be very valuable for others who could be having the same problems with installation. It is unfortunate that the installation process for php_beautifier is so poor.


Reply to this email directly or view it on GitHub.

@joeguilmette
Copy link
Author

It seems that you can add a line to the Atom Beautify settings for users to add command line arguments so that we can toggle filters on and off there, as we would when calling php_beautifier via the command line.

see: http://beautifyphp.sourceforge.net/docs/PHP_Beautifier/tutorial_PHP_Beautifier.howtouse.commandline.pkg.html#command.command_usage

Also, we can use callbacks within the specific files, but it seems that they are not working. This could be an Atom Beautify thing, or a PEBKAC thing, not sure.

In any case, the ArrayNested filter seems to be the one I'm after.

@Glavin001 Glavin001 changed the title using filters with php_beautifier Add config option for PHP Beautifier filters Oct 8, 2014
@Glavin001
Copy link
Owner

I am having some issues with using php_beautifier itself:

$ php_beautifier

Warning: require_once(PEAR.php): failed to open stream: No such file or directory in /Users/glavin/pear/bin/php_beautifier on line 37

Fatal error: require_once(): Failed opening required 'PEAR.php' (include_path='.:') in /Users/glavin/pear/bin/php_beautifier on line 37

Until I am able to resolve this I cannot test any changes that I make that are for PHP beautification.
PHP_Beautifier has been such a problem as of late..

@Glavin001
Copy link
Owner

If you need a solution soon, you could try editing the Atom Beautify package yourself and see if you can get it working. If so, please submit a Pull Request!
This is where you would add any options and create the Terminal command that is executed: https://github.com/Glavin001/atom-beautify/blob/master/lib/langs/php-beautify.coffee#L4-L13
Hope this helps!

@karljakober
Copy link

This is useless for us php developers without this setting!

@Glavin001
Copy link
Owner

Published to v0.17.1

Added options:

  • php_filters
  • php_directory_filters

As stated above, I am unable to test as I cannot get PHP_beautifier to work on my computer. Please test this and let me know if this is working or not. Thank you for your patients.

@karljakober
Copy link

Works beautifully. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants