PHPer
PHPer

Reputation: 664

Using Laravel Package Classes Into Another

I created a simple Laravel package that I have already deployed to GitHub and Packagist successfully. It can be installed via Composer as expected.

Now...

I am creating a second package that would use the first one's functionality, but it is not showing.

In the current package, I do: use Me\Package\Models\Extra, in the controller of my second package and, I get the class is not found.

I tried using the ServiceProvider register() function, but it doesn't work.

Upvotes: 0

Views: 50

Answers (1)

common sense
common sense

Reputation: 3912

Use Composer to install your first package into the second package:

Lets call the first package codiiv/first-package.

Go the project root of your second package and type this command to your terminal: composer require codiiv/first-package.

Upvotes: 1

Related Questions