1

I am trying to install Nette2.3.1 using Composer (on XAMPP). In c:\x\php folder I run this command:

composer create-project nette/sandbox myprojectname

When I do this, getting following error:

[Seld\JsonLint\ParsingException] "c:\x\php\php.exe" does not contain valid JSON Parse error on line 1: MZÉ ♥ ♦    ╕ ^ Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

I tried all these options to no avail:

  1. removed the project directory and tried
  2. ran this command inside htdocs folder
  3. ran this through PHP JetBrains console
  4. made sure that the Composer version is the latest one

What was wrong?

This was what went wrong:

  1. I installed xampp while anti-virus is running - i got a warning but chose to ignore that. Consequently php.exe was corrupted and messed up the whole thing for me.

  2. PATH variables under my user wasn't updated with php.exe path. Though system variable is updated, it is still a mystery to me why this became an issue.

How I did to correct this:

Removed xampp altogether, cleared composer cache and installed wamp this time and created project for nette sandbox. This worked fine. In all fairness xampp would have worked as well had I installed it with av disabled and PATH variables properly updated.

Pura
  • 141
  • 1
  • 6
  • This command works fine for me... maybe there's something wrong with your Composer installation. Are you running the latest version (`composer --version`)? Try `composer selfupdate`. Or maybe try to get fresh version from getcomposer.org/download or use stand-alone phar composer... – Ondra Koupil May 04 '15 at 17:04
  • @Ondra how do i use stand-alone phar composer? – Pura May 05 '15 at 04:48
  • You can download phar from https://getcomposer.org/download/ - Manual Download section. Download the file and save it somewhere. Then you navigate in command line to the file (`cd c:\somewhere\elsewhere`) and run it as it was plain PHP file, i.e. `php composer.phar --version`. You might need to use complete path to PHP if your PATH is broken or wrongly set, i.e. `c:\x\php\php.exe composer.phar --version` – Ondra Koupil May 05 '15 at 14:26

1 Answers1

1

I think your composer PATH or shortcut/batch file is kind of broken, because it tries to read the php.exe file as a JSON file.

Try to remove composer completely and start with a clean install

  1. Download and install composer using the automated installer. It sets up the PATH for you, so you can just call composer from anywhere.
  2. Close the command line terminal and start a new one (important).
  3. Try to run the composer create-project nette/sandbox myprojectname command in any directory

Documentation - windows installation of composer

samuel
  • 326
  • 2
  • 9
  • Thanks Samuel. Yes, apparently php.exe is also corrupt. While installing xampp I chose to ignore the warning that antivirus is running during the installation and that might create problems later. Now, I uninstalled xampp, disabled av and ran xampp installation again >> added path variables. both PHP and Composer are running fine on command line. Now I will have to create composer.json file for nette and place it where? in the project folder under htdocs (or www in wamp)? In which case should I change directory of the comand line to the project folder and run 'composer create project' command? – Pura May 06 '15 at 06:36
  • if you want to try nette sandbox, you don't need to create composer.json file by yourself. just go to the htdocs directory and run the `composer create-project nette/sandbox myprojectname` command, it will create a new subdirectory called **myprojectname** and there will be a copy of nette sandbox and all its dependencies. with composer.json and composer.lock already in there (json is get from the repo https://github.com/nette/sandbox and lock file is generated during the create-project command). and you are done, check the http://localhost/myprojectname/www/ – samuel May 06 '15 at 10:52
  • yeah, now it is working fine - i removed xampp and installed wamp instead. ran composer create-project nette/sandbox myproject and it is fine now. Thanks a lot to everyone. – Pura May 06 '15 at 14:16
  • I am trying (use Nette\Application\UI;) without parenthesis to access Presenter.php - one of the library files under UI. My project file in which this expression is used is in the project root folder. But i am getting error that use couldn't be analyzed. the given path is not being resolved. then I placed the project file in (vendor\nette\application\src) to no avail. What am I doing wrong? – Pura May 06 '15 at 15:14