Codeigniter Compoer Autoload But No Composer.json file

I have been given a new project using codeigniter and have come across a very strange issue.

The config is set to use the composer autoloader and there are a few packages already installed. There doesnt seem to be a composer.json file in the project which is causing me an issue when I am trying to install a new package. (I am also confused how the currect packages are working/installed without the composer.json file)

I need to install the oAuth2-Client package using composer, I downloaded the project locally (due to not having ssh access), created a composer.json file in the application directory and then ran the composer require {package} command.

The package was successfully installed and then I reimported my new local project to the server via SFTP but now none of the original package namespaces can be found, all the files exist but the autoloader must have been overwritten.

Is there a way to someone install the new package and as keep the autoloader working for the currect packages?

Here is the original composer/autoload_classmap.php and composer/autoload_static.php files which seem to be the only place which creatings the mapping

<?php

// autoload_classmap.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'WfmClient\\Endpoints' => $vendorDir . '/wfm-client/src/Endpoints.php',
    'WfmClient\\HttpClient' => $vendorDir . '/wfm-client/src/HttpClient.php',
    'WfmClient\\JobResource' => $vendorDir . '/wfm-client/src/JobResource.php',
    'WfmClient\\Model' => $vendorDir . '/wfm-client/src/Model.php',
    'WfmClient\\PurchaseOrderResource' => $vendorDir . '/wfm-client/src/PurchaseOrderResource.php',
    'WfmClient\\TimeSheetResource' => $vendorDir . '/wfm-client/src/TimeSheetResource.php',
    'WfmClient\\WfmResource' => $vendorDir . '/wfm-client/src/WfmResource.php',
);
<?php

// autoload_static.php @generated by Composer

namespace Composer\Autoload;

class ComposerStaticInit2d3d78f35a428a0ffb242835d26c2dbf
{
    public static $files = array (
        'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
        'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
        '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
    );

    public static $prefixLengthsPsr4 = array (
        'P' => 
        array (
            'Psr\\Http\\Message\\' => 17,
        ),
        'G' => 
        array (
            'GuzzleHttp\\Psr7\\' => 16,
            'GuzzleHttp\\Promise\\' => 19,
            'GuzzleHttp\\' => 11,
        ),
    );

    public static $prefixDirsPsr4 = array (
        'Psr\\Http\\Message\\' => 
        array (
            0 => __DIR__ . '/..' . '/psr/http-message/src',
        ),
        'GuzzleHttp\\Psr7\\' => 
        array (
            0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
        ),
        'GuzzleHttp\\Promise\\' => 
        array (
            0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
        ),
        'GuzzleHttp\\' => 
        array (
            0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
        ),
    );

    public static $classMap = array (
        'WfmClient\\Endpoints' => __DIR__ . '/..' . '/wfm-client/src/Endpoints.php',
        'WfmClient\\HttpClient' => __DIR__ . '/..' . '/wfm-client/src/HttpClient.php',
        'WfmClient\\JobResource' => __DIR__ . '/..' . '/wfm-client/src/JobResource.php',
        'WfmClient\\Model' => __DIR__ . '/..' . '/wfm-client/src/Model.php',
        'WfmClient\\PurchaseOrderResource' => __DIR__ . '/..' . '/wfm-client/src/PurchaseOrderResource.php',
        'WfmClient\\TimeSheetResource' => __DIR__ . '/..' . '/wfm-client/src/TimeSheetResource.php',
        'WfmClient\\WfmResource' => __DIR__ . '/..' . '/wfm-client/src/WfmResource.php',
    );

    public static function getInitializer(ClassLoader $loader)
    {
        return \Closure::bind(function () use ($loader) {
            $loader->prefixLengthsPsr4 = ComposerStaticInit2d3d78f35a428a0ffb242835d26c2dbf::$prefixLengthsPsr4;
            $loader->prefixDirsPsr4 = ComposerStaticInit2d3d78f35a428a0ffb242835d26c2dbf::$prefixDirsPsr4;
            $loader->classMap = ComposerStaticInit2d3d78f35a428a0ffb242835d26c2dbf::$classMap;

        }, null, ClassLoader::class);
    }
}


Read more here: https://stackoverflow.com/questions/64949920/codeigniter-compoer-autoload-but-no-composer-json-file

Content Attribution

This content was originally published by Luke Rayner at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: