Marc Steven Plotz Marc Steven Plotz - 6 months ago 31
PHP Question

Valet Install On Mac - Cannot Redeclare

I'm installing Valet on my MacBook Pro - El Capitan.

I installed PHP and MySQL with Homebrew as suggested on the Valet documentation page.

However, when I try to install Valet, I get the error:


PHP Fatal error: Cannot redeclare resolve() (previously declared in /Users/marc/.composer/vendor/hoa/core/Protocol.php:1140) in /Users/marc/.composer/vendor/laravel/valet/cli/includes/helpers.php on line 57

Fatal error: Cannot redeclare resolve() (previously declared in /Users/marc/.composer/vendor/hoa/core/Protocol.php:1140) in /Users/marc/.composer/vendor/laravel/valet/cli/includes/helpers.php on line 57


My composer.json file looks like this:

{
"require": {
"phpunit/phpunit": "~4.2",
"phpmetrics/phpmetrics": "^1.10",
"laravel/valet": "^1.1"
}
}


I have tried deleting composer.lock and deleted the vendor directory, then
composer install
, but nothing changes. Any one have any advice here?

Answer

Basically there are 2 methods called the same thing, one in /Users/marc/.composer/vendor/hoa/core/Protocol.php line 1140

and the other in /Users/marc/.composer/vendor/laravel/valet/cli/includes/helpers.php on line 57.

A quick fix would be to remove the phpmetrics/phpmetrics dependency and run composer install again

Good thing is that in both places they check if the function exists, so you can declare it yourself.

If declare your own version before the vendor/autoload.php file is loaded, if you have control over this. So you could declare it to do what it currently does in Laravels helpers.php

Comments