PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, March 14, 2022

[FIXED] How to make custom libraries in Laravel - as in codeigniter

 March 14, 2022     codeigniter, laravel     No comments   

Issue

i'm used to write a lot in codeigniter, where i try to place all logic code inside libraries instead of controllers.

The idea is a controller calls a library that calls a model to get data. So whatever is happening inside a library, can be called from multiple controllers easily, without rewriting code.

Now i'm baby stepping to laravel and i cannot find anything about custom libraries. I perfectly managed to call a model from a controller, but I want to have a controller calling a library and the library calling the model.

I'm not able to find libraries (not packages), do they exist in laravel ?

Thank you.


Solution

Laravel works with Services and Providers, you create your service and write a provider for it. Laravel Providers

Also you can have Services Directory which is served through Providers Directory.



Answered By - anwerj
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing