Download the PHP package veseluy-rodjer/laravel-service-generator without Composer

On this page you can find all versions of the php package veseluy-rodjer/laravel-service-generator. 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-service-generator


Laravel Service Generator

Quickly generate services for your projects!



Table of Contents

  1. Features
  2. Installation
  3. Usage
    • Generate services
    • Generate services for models
    • Generate services for controllers
  4. The service pattern
    • When to use the service pattern
    • How to use services
      • Static methods
      • Dependency Injection
  5. More generator packages
  6. Contributing
  7. License

Features

This package adds the command. The command generates an empty service class in to get started. I made this mainly for own use because I like to be able to generate recurring files from the command line to keep my workflow consistent.

Installation

Install the package with composer.

Usage

After installation the will be available in the list of artisan commands.

Generate Service

To generate a new service use the following artisan command.

Generate a service for a model

Add a or param to generate a service for the model.

Use the or param to generate a service, migration, seeder, factory, policy, and resource controller for the model.

Generate a service for a controller

Add a or param to generate a service for the controller.

The service pattern

When to use the service pattern

A common question is: where do I put my business logic? You want to keep your models thin and your controller functions skinny. There are multiple ways to archive this, extracting your business logic to the service layer is a common method. By encapsulating your business logic in a service class you are able to re-use the logic for example in your controllers, commands, jobs and middelware.

How to use services

Once you have made a service it is time to add your business logic. We will discus how to use a service via static methods, dependency injection and how to use it with interfaces and repositories.

Static methods

a common way to use a service is to call it's methods statically. It is similar to helper functions. Let's say we have a with a method to get a post based on a slug.

Next you can include the service class for example your controller and call the method statically.

The method is in this example a very simple function but as you can see it keeps you controller skinny and and your business logic seperated. Keep in mind that static classes and methods are stateless. The class won't save any data in itself.

Dependency Injection

Another popular method is to use services with dependency injection. With dependency injection you can write loosely coupled code. When done right this will improve the flexibility and maintainability of your code.

The we used as example before will remain almost the same except we don't declare the functions inside the class as static anymore.

Next we inject the service into the constructor of the class where we want to use it. Inside the constructor we assign the object to the class property. Now the property will be callable in all functions within the class with . While typing your IDE will already typehint the functions in your PostService class, in this case only .

More generator packages

Looking for more ways to speed up your workflow? Make sure to check out these packages.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-service-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
symfony/console Version ^5.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 veseluy-rodjer/laravel-service-generator contains the following files

Loading the files please wait ....