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

FIX: Check if simpleDispatcher() / cachedDispatcher() are already defined. #39

Closed
wants to merge 1 commit into from

Conversation

sstruk
Copy link
Contributor

@sstruk sstruk commented Mar 27, 2015

Problem : PHP Fatal error: Cannot re-declare FastRoute\simpleDispatcher()

When developing a package ( e.g. in Laravel workbench ) that depends on FastRoute, issue occurs when both main project and package have a dependency on FastRoute.

Issue is that code in functions.php doesn't check if those two functions are already defined, and PHP dies when it tries to include the FastRoute from dev package vendor / FastRoute folder ( as it already is defined in main project vendor / FastRoute ).

@nikic
Copy link
Owner

nikic commented Mar 27, 2015

Why would that file be included twice? If a project depends on FastRoute twice, composer should still include the bootstrap only once.

@sstruk
Copy link
Contributor Author

sstruk commented Mar 28, 2015

If you check composer.json you'll see

    "autoload": {
    "psr-4": {
      "FastRoute\\": "src/"
    },
    "files": ["src/functions.php"]
  }

And that loads the file on every request, and since project is included on two different locations file gets loaded twice.

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

Successfully merging this pull request may close these issues.

None yet

2 participants