Support the ongoing development of Laravel.io →
Packages Architecture
Last updated 2 years ago.
0
  1. learn how to create a package
  2. bind it in a loC container
  3. create a provider and a facade
  4. deploy on packagist if you like
Last updated 2 years ago.
0

If the Table.php class is a independent class with no other dependencies. You can also load them as you would load another Service class.

All you need to do is :

Specify the App directory in composer.json :

		"psr-0":{
			"Myapp":"app/"
		}

In you can drop the class anywhere for this example , app/Myapp/Lib/Table.php

<?php namespace Myapp\Lib;

class Table .... // You table class

In your controller

<?php 

use Myapp\Lib\Table as Table;

class Mycontroller ....

protected $table;

public function __contruct(Table $t){
   $this->table = $t;
}

When you type hint the class it should get injected since you don't have much ambiguity on which class the app container should load.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

shahroq shahroq Joined 14 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.