![]() |
Codeigniter and Composer psr-4 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Codeigniter and Composer psr-4 (/showthread.php?tid=67604) Pages:
1
2
|
Codeigniter and Composer psr-4 - phpforever2017 - 03-14-2017 Hi guys composer.json Code: { application/libraries PHP Code: <?php application/controllers PHP Code: <?php PHP Code: Fatal error: Class 'App\Libraries\Welcome_library' not found What am I doing wrong. Thanks RE: Codeigniter and Composer psr-4 - Narf - 03-14-2017 Not actually using Composer's autoloader? RE: Codeigniter and Composer psr-4 - phpforever2017 - 03-14-2017 (03-14-2017, 11:11 AM)Narf Wrote: Not actually using Composer's autoloader? In config set composer autoload true php 5.5 codeigniter 3.1.3. Composer installing. RE: Codeigniter and Composer psr-4 - phpforever2017 - 03-14-2017 (03-14-2017, 11:11 AM)Narf Wrote: Not actually using Composer's autoloader? In config set composer autoload true php 5.5 codeigniter 3.1.3. Composer installing. You talk about it require __DIR__ . '/vendor/autoload.php RE: Codeigniter and Composer psr-4 - Narf - 03-15-2017 Setting it to TRUE means that it will look for application/vendor/autoload.php Is that the correct path for your setup? If not, set it to the path to the autoload.php file. RE: Codeigniter and Composer psr-4 - phpforever2017 - 03-16-2017 (03-15-2017, 02:57 AM)Narf Wrote: Setting it to TRUE means that it will look for application/vendor/autoload.php Thanks Narf. I just forgot to add to the index.php PHP Code: require FCPATH.'vendor'.DIRECTORY_SEPARATOR.'autoload.php'; RE: Codeigniter and Composer psr-4 - Narf - 03-16-2017 You don't need to add it to index.php ... RE: Codeigniter and Composer psr-4 - llebkered - 03-16-2017 There are 2 ways. One is a simple change to your config. The other is including a link in your index.php. Changing the config is the best because it doensn't breaak the coding commandment: "Thou shalt not hack thine core". Method 1: Change the following in application/config/config.php. $config['composer_autoload'] = './vendor/autoload.php'; (or where ever your autoload.php is located) Method 2: You can also add include_once './vendor/autoload.php'; to index.php as per Phil Sturgeon's blog https://philsturgeon.uk/php/2012/05/07/composer-with-codeigniter/ RE: Codeigniter and Composer psr-4 - phpforever2017 - 03-16-2017 Removed from index.php and set in config $config['composer_autoload'] = 'vendor/autoload.php'; Everything works fine, thanks. This is all my inattention. RE: Codeigniter and Composer psr-4 - phpforever2017 - 03-16-2017 (03-16-2017, 04:51 AM)llebkered Wrote: There are 2 ways. One is a simple change to your config. The other is including a link in your index.php. Changing the config is the best because it doensn't breaak the coding commandment: "Thou shalt not hack thine core". Thanks, understood |