Martijn
Martijn

Reputation: 2324

Migrating Libraries from Codeigniter to Laravel

I'm trying to migrate my app from code igniter to laravel. I have a lot of custom self written libraries that also need to be transferred over. In code igniter I simply put my Libs inside the app/libraries folder and I can load them in very easily. I can just do $this->load->library('someclass'); and $this->someclass->some_function(); and it works. Now I have been looking for ways to accomplish the same on laravel but I didn't manage to find anything. I have tried a lot of them but they didn't seem to work. Do you guys have any idea on how I can do this?

Much appreciated!

Upvotes: 0

Views: 1663

Answers (1)

Connor Peet
Connor Peet

Reputation: 6265

Namespacing is your answer. Put them all in a namespace, so open a script with <?php namespace Library; Add app/libraries to the autoload.classmap in your composer.json. Then after placing all your libraries in there, run php composer.phar dump-autoload. You'll then be able to access any library by just calling, for example$class = new Library\someclass();!

Upvotes: 1

Related Questions