Composer Fatal error: Cannot redeclare composerRequire
Asked Answered
B

1

5

When running the PHP Development server on my MacOS I get the following error from composer.

Fatal error: Cannot redeclare composerRequire01a3dc0b1f885ed2b645be37711584c1() 
(previously declared in /Users/<user>/Desktop/<app>/vendor/composer/autoload_real.php:63) 
in /Users/<user>/Desktop/<app>/vendor/composer/autoload_real.php on line 70

However when running this exact same code on my Windows box everything seems to run perfectly fine. I've verified that I am not including the require statement for the autoload more than once. What could be causing this? I'm using the Composer from HomeBrew if that makes any difference. I just can't see how such a specific file namespace as that could be getting included multiple times.

EDIT

Composer autoload_real.php

<?php

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit01a3dc0b1f885ed2b645be37711584c1
{
    private static $loader;

    public static function loadClassLoader($class)
    {
        if ('Composer\Autoload\ClassLoader' === $class) {
            require __DIR__ . '/ClassLoader.php';
        }
    }

    public static function getLoader()
    {
        if (null !== self::$loader) {
            return self::$loader;
        }

        spl_autoload_register(array('ComposerAutoloaderInit01a3dc0b1f885ed2b645be37711584c1', 'loadClassLoader'), true, true);
        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
        spl_autoload_unregister(array('ComposerAutoloaderInit01a3dc0b1f885ed2b645be37711584c1', 'loadClassLoader'));

        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
        if ($useStaticLoader) {
            require_once __DIR__ . '/autoload_static.php';

            call_user_func(\Composer\Autoload\ComposerStaticInit01a3dc0b1f885ed2b645be37711584c1::getInitializer($loader));
        } else {
            $map = require __DIR__ . '/autoload_namespaces.php';
            foreach ($map as $namespace => $path) {
                $loader->set($namespace, $path);
            }

            $map = require __DIR__ . '/autoload_psr4.php';
            foreach ($map as $namespace => $path) {
                $loader->setPsr4($namespace, $path);
            }

            $classMap = require __DIR__ . '/autoload_classmap.php';
            if ($classMap) {
                $loader->addClassMap($classMap);
            }
        }

        $loader->register(true);

        if ($useStaticLoader) {
            $includeFiles = Composer\Autoload\ComposerStaticInit01a3dc0b1f885ed2b645be37711584c1::$files;
        } else {
            $includeFiles = require __DIR__ . '/autoload_files.php';
        }
        foreach ($includeFiles as $fileIdentifier => $file) {
            composerRequire01a3dc0b1f885ed2b645be37711584c1($fileIdentifier, $file);
        }

        return $loader;
    }
}

function composerRequire01a3dc0b1f885ed2b645be37711584c1($fileIdentifier, $file)
{
    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
        require $file;

        $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
    }
}
Brython answered 1/10, 2017 at 0:14 Comment(4)
can you paste the /vendor/composer/autoload_real.php generated by composer here?Unlicensed
@Unlicensed AddedBrython
Why those class and function names tho?Voe
I haven't touched this, I simply copied whats in the file. I'd assume Composer generated this on its own.Brython
K
14

It seems you made a copy of an existing project directory and try to tun it in a new directory

Try to delete composer.lock and vendor/ and run composer update

I'm not 100% sure but hope it will help

Kirby answered 5/10, 2017 at 20:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.