Giter Club home page Giter Club logo

Comments (24)

Glavin001 avatar Glavin001 commented on August 24, 2024

Could you show what your editor's source code is? (which is the input text to the PHP beautifier)

If an error occurred in the beautification process of your PHP source code, the output file may not have been created and therefore when the call to delete temporary output file was executed it was unnecessary (there is no existing output file since an error had occurred) and it errored again because it was attempting to delete a file that does not exist.

from atom-beautify.

BOOMER74 avatar BOOMER74 commented on August 24, 2024

Same trouble, code not formatted:
image
Beautifier work, but with warnings, like "Strict standards: Non-static method PEAR::isError() should not be called statically". PHP 5.5.11. PHP_Beautifier 0.1.15.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

Please paste your source code so I can quickly test later without having to retype and possibly mistype your code. Thank you for posting version numbers @BOOMER74

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

So I am using:

<?php
function add($a,     $b) {
  return $a +$b; }
echo   add(1,2);

and it beautifies correctly.

I will add a little more logging in the Console that you can send me to debug.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

v0.4.4 is the version with additional logging. Let me know how that goes.

from atom-beautify.

BOOMER74 avatar BOOMER74 commented on August 24, 2024

Log this: Beautifcation Error: Error {killed: false, code: 1, signal: null}

from atom-beautify.

AndalfTheBeard avatar AndalfTheBeard commented on August 24, 2024

Hey, sorry I didn't respond to this sooner. Only recently got atom installed and running again, it appears that the initial error I was having no longer occurs but I'm running into a new one now regardless. Using various code examples, and for consistencies sake, the one posted above too, I'm getting the following error:

Uncaught TypeError: Cannot read property 'split' of undefined /usr/local/share/atom/resources/app/node_modules/text-buffer/lib/range.js:48

No idea why that would be happening.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

Glad to hear the previous error is no longer persisting, @AndalfTheBeard.

That new error looks like the result of the beautification is undefined instead of a string containing the beautified source code. Can you confirm what version of Atom, Atom Beautify, and php_beautify you have, as well as some sample source code I can test for myself.

from atom-beautify.

AndalfTheBeard avatar AndalfTheBeard commented on August 24, 2024

Atom Version 0.121.0
Atom Beautify 0.6.2
PHP_Beautifier-0.1.15

running Xubuntu 14.04 LTS

I've tried various code samples, all resulted in the same error.

<?php
function add($a,     $b) {
  return $a +$b; }
echo   add(1,2);

included, as it was the example you provided above.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

My beautification is working properly.

Before

<?php
function add($a,     $b) {
  return $a +$b; }
echo   add(1,2);

After:

<?php
function add($a, $b) {
    return $a + $b;
}
echo add(1, 2);

This (and even the previous error you and @BOOMER74 are experiencing) could be caused by an incorrect PATH environment variable, and therefore it cannot find php_beautifier.

Could you retrieve the php_beautifier path using which php_beautier. Mine for instance:

$ which php_beautifier
/Users/glavin/pear/bin/php_beautifier

And set your php_beautifier_path variable in either your .jsbeautifyrc file or in your Atom Beautify package settings:

image

I have put in some special code as a workaround for Node.js's issue with the PATH environment variable with using exec: https://github.com/Glavin001/atom-beautify/blob/master/lib/langs/cli-beautify.coffee#L40-L49

However, it may not be working in you cases. So by forcing the php_beautifier_path, you should then be using the proper command and it should hopefully work not. Keep me posted!

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

from atom-beautify.

BOOMER74 avatar BOOMER74 commented on August 24, 2024

@Glavin001 I have install atom-beautify and php_beautifier to third PC. Formatting work good. The problem was in the wrong PEAR paths when installing php_beautifier. Today I check this on other PC.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

Thanks for checking @BOOMER74. I will be adding more setup document for languages like PHP that require the PATH ( #58 ). Hopefully that will help users like yourselves in the future from having this issue.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

@AndalfTheBeard could you confirm if that was your issue as well?

from atom-beautify.

AndalfTheBeard avatar AndalfTheBeard commented on August 24, 2024

having purged php5, php5-cli and php-pear then reinstalling, along with running

sudo pear install --alldeps php_beautifier-0.1.15

I am still unable to get this to work. which php_beautifier returns absolutely nothing for me in the terminal however I'm sure that php_beautifier is installed and I can find the file in ~/pear/bin/php_beautifier setting that to the path just results in this

cmd: "/bin/sh -c [ -f ~/.bash_profile ] && source ~/.bash_profile;[ -f ~/.bash_rc ] && source ~/.bash_rc;php "~/pear/bin/php_beautifier" "/tmp/input114713-3313-1uewpzf" "/tmp/114713-3313-iifrnm""
code: 1
killed: false
message: "Command failed: /bin/sh -c [ -f ~/.bash_profile ] && source ~/.bash_profile;[ -f ~/.bash_rc ] && source ~/.bash_rc;php "~/pear/bin/php_beautifier" "/tmp/input114713-3313-1uewpzf" "/tmp/114713-3313-iifrnm"↵"
signal: null
stack: (...)
get stack: function () { [native code] }
set stack: function () { [native code] }
__proto__: d

I have no idea what is happening here.

trying to use php_beautifier -help results in the reponse php_beautifier: command not found even when I'm cded into the same folder as it.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

To execute a command, even when in the same directory, you should prefix you command with ./
So it should look like: ./php_beautifier --help
Furthermore, php_beautifier is a PHP script, which is why I also prefix it with php to force PHP to interpret the script. Your terminal should detect it is a PHP script if the script has the proper headings.

If you can get php_beautifer to work with the above, then we know it is correctly installed.

Instead of using the ~ symbol in the settings path exchange that for the full absolute path, for instance mine is /Users/Glavin/ instead of ~. Sometimes that causes problems.

Besides that, you generated command from atom beautify looks correct. You should test your source code with php_beautifier directly via command line and see the result. If that works via command line and does not work via atom beautify, then I have an issue to resolve.

from atom-beautify.

AndalfTheBeard avatar AndalfTheBeard commented on August 24, 2024
andy@Porrim:~$ cd pear/bin
andy@Porrim:~/pear/bin$ ls
docblockgen     pci      pear     pecl            php_beautifier.bat
gen_php_doc.sh  pciconf  peardev  php_beautifier  scripts
andy@Porrim:~/pear/bin$ ./php_beautifier -help
PHP Warning:  require_once(PHP/Beautifier.php): failed to open stream: No such file or directory in /home/andy/pear/bin/php_beautifier on line 49
PHP Fatal error:  require_once(): Failed opening required 'PHP/Beautifier.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/andy/pear/bin/php_beautifier on line 49
andy@Porrim:~/pear/bin$ 

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

Not quite sure why you insist on using the long option help with only a single - (used for short options). See Command line documentation: http://beautifyphp.sourceforge.net/docs/PHP_Beautifier/tutorial_PHP_Beautifier.howtouse.commandline.pkg.html#command.options

It should be: ./php_beautifier --help (notice the double -, so --help, NOT -help. If you want to use just one - then use the short option, -?). It is failing to parse your incorrect usage and assuming there is instead a file to open, showing error failed to open stream: No such file or directory in.

from atom-beautify.

AndalfTheBeard avatar AndalfTheBeard commented on August 24, 2024

-help --help and -? all result in the same error anyway, so that's not at all what's happening.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

At least we can now guarantee we are using it as expected.

Sounds like your installation of php_beauifier is broken. This is a php_beautifier issue and you can follow up with them (or do some independent research) and see if they have any experience with this issue.
Once you have php_beautifier working on your machine then we can resume verifying if there are any problems with Atom Beautify.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

I am closing this as it appears resolved from an Atom Beautify perspective. Looks like it was a php_beautifier installation issue. / wrong pear path as @BOOMER74 mentioned.

from atom-beautify.

BOOMER74 avatar BOOMER74 commented on August 24, 2024

Ok, if you have this problem try this:

  • Uninstall PHP_Beautifier
  • Type commands and check path:
    • pear config-get data_dir
    • pear config-get test_dir
    • pear config-get doc_dir
  • If paths incorrect, set paths:
    • pear config-set data_dir C:\php\data
    • pear config-set test_dir C:\php\tests
    • pear config-set doc_dir C:\php\docs
  • Install PHP_Beautifier again with all deps:
    • pear install -a channel://pear.php.net/php_beautifier-0.1.15

from atom-beautify.

AndalfTheBeard avatar AndalfTheBeard commented on August 24, 2024

Can confirm it was a bad install of PHP_Beautifier, not sure how but I managed to fix it. Thanks for the help.

from atom-beautify.

Glavin001 avatar Glavin001 commented on August 24, 2024

Glad to hear it's working out for everyone. Good to have this discussion available for other Atom Beautify and PHP_Beautifier users. Thanks guys!

from atom-beautify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.