Download the PHP package lambertns/laravel-make-service without Composer

On this page you can find all versions of the php package lambertns/laravel-make-service. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-make-service

Laravel Make Service

A Laravel package that adds a make:service command to generate service classes with optional dependency injection into controllers.

Why Use Services?

Controllers can quickly become bloated with business logic, making them hard to maintain and test. Services help by:

Example Problem

Without Services (Fat Controller):

With Services (Clean Controller):

Features

Installation

You can install the package via Composer:

That's it! The package will automatically register the service provider.

Quick Start

Let's say you have a controller with lots of business logic and want to refactor it:

  1. Create a service to extract the logic:

  2. Your service is created and automatically injected:

  3. Use it in your controller:

Usage

Basic Service Creation

Create a simple service:

This will create app/Http/Services/UserService.php:

Create Service with Methods

Add methods to your service:

This creates a service with three methods:

Auto-Inject into Controller

Automatically inject the service into a controller:

This will:

  1. Create app/Http/Services/PaymentService.php
  2. Add use App\Http\Services\PaymentService; to the controller
  3. Add constructor injection with property promotion:

Inject into Multiple Controllers

Inject the service into multiple controllers at once (comma-separated):

This will inject the service into all three controllers and show a summary:

Inject into Existing Controller

You can also add services to controllers that already have dependencies:

If the controller already has a constructor with dependencies, the new service will be added:

Command Options

Option Description Example
--controller Controller(s) to inject into (comma-separated for multiple) --controller=AuthController,UserController
--methods Comma-separated list of method names --methods="index,store,update"
--force Overwrite existing service --force

Examples

Create a service with multiple methods and inject into multiple controllers:

This will create the OrderService with three methods and inject it into both controllers.

Use in nested namespaces:

Requirements

Features

Constructor Property Promotion

This package uses PHP 8's constructor property promotion for clean dependency injection:

This eliminates the need for separate property declarations and manual assignment.

Smart Use Statement Insertion

The package intelligently adds use statements in the correct location:

Troubleshooting

Service not being injected?

  1. Make sure the controller exists
  2. Check that the controller has a valid namespace
  3. Verify the controller file is writable

License

This package is open-sourced software licensed under the MIT license.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If you encounter any issues or have questions, please open an issue on GitHub.


All versions of laravel-make-service with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/support Version >=10.0
illuminate/console Version >=10.0
illuminate/filesystem Version >=10.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lambertns/laravel-make-service contains the following files

Loading the files please wait ...