Download the PHP package okaybueno/service-generator without Composer

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

IMPORTANT ❗

This package has been discontinued and it won't receive any other updates. If you're using it please consider migrating to another solution – or fork it and depend on your own version of package.


Service Generator

A package to automatically generate services and validators for your Laravel apps.

Latest Version on Packagist Quality Score Total Downloads

Goal

There are lots of different ways to architect your web apps. One of those ways is the so called "Hexagonal architecture", which far from being as new and hype as micro-services just puts on thing clear on the table: separating of concerns in n-tiers, so each layer provides certain functionality to the layer above, and uses some functionality from the layer below, by using contracts or interfaces that provide entry points for the functionality living in each one of those layers. We know: it's a bit abstract. You can read more about this architecture here and here.

At okay bueno we are concerned about moving fast and iterating efficiently on digital products. That means also optimising the way the work and automating steps that are tedious and monotonous. One of those steps is the process of creating the different services that compound our apps. It's always the same: you have to create the interface and then the implementation, and in most of the cases you also need to create validators and repositories and inject them. After that you have to create the service provider and wire things up. Those files contain the same skeleton all the times, so this package provides an interactive way of creating these services via the CLI.

Installation

  1. Install this package by adding it to your composer.json or by running composer require okaybueno/service-generator in your project's folder.
  2. For Laravel 5.5 the Service provider is automatically registered, but if you're using Laravel 5.4, then you must add the provider to your config/app.php file: OkayBueno\ServiceGenerator\ServiceGeneratorServiceProvider::class
  3. Publish the configuration file by running php artisan vendor:publish --provider="OkayBueno\ServiceGenerator\ServiceGeneratorServiceProvider"
  4. Open the configuration file (config/service-generator.php) and configure the settings according to your needs.
  5. Ready to go!

Usage

This package simple provides a generator command to bootstrap the files that compound a certain service. Therefore the only functionality provided is a command that will ask you a few questions and will create and wire things up, so you don't have to do it manually.

The package is required only during development, so feel free to use it only during development and not on production.

Examples

NOTE: This piece of text is heavily biased. This is the way I like to split my code, but you don't necessarily have to do it like this.

Our app will be divided in 3 groups of services: frontend (used by the API and other methods exposed to the public), backend (used by our backend app), and shared (services or methods that are shared across both backend and frontend).

In each of these folders we have another separation of concerns, so the services for our Users will go into a folder, the services for our Invoices will go to another folder, and so on... Same way, each of these services will contain the validation on its own, provided by another of our packages (required by this package).

All in all, the final structure would look like this:

Generator

Yeah, creating all those files, link them up, inject validators and repositories is a bummer. Also for me. So what if we automate that, so we can spend more time doing cool things (like actually writing some code!)?

Just execute php artisan make:service {service}, where {service} is just the name of the group-service that you want to create (for example, php artisan make:service Users) and then just follow the steps on the screen :).

1st step: Selecting the group

As you have seen, the config/service-generator.php contains just one parameter to configure: namespace and location of all the different folders that can keep services. The first step on the interactive prompt is to select the group for which this service is. You can do that by just selecting the option on the given screen:

2nd step: A) Injecting repository (optional)

Pretty often our services will be using more or more than one repository, so you can inject it at this point. The console will ask you if you want to inject a repository. If you select yes, then you'll be prompted to introduce the full class name of the repository (or interface) that you want to inject. If you select not (selected by default), then you can move to step 3.

2nd step: B) Selecting repository (optional)

If you selected "yes" to the injection of a repository, then you have to introduce the full class name of the repository that you want to inject. Our advices is to inject a repository and bind the interface to a class, resolved by the IoC container that Laravel offers:

3rd step: Creating and injecting a validator and its interface (optional)

Sometimes you may also need to validate the data inside the repository, so in these cases you might want to create and inject a validator. If you select "yes" (selected by default) then a validator interface and its implementation in Laravel will be generated, following the structure from our example above. If you select "no", then no validation services will be created:

4th step: Wiring the service provider up

A service provider will be created as well, so the last step is to wire that service provider to our application. To do, just add a normal service provider the same way that you would add it if you were creating this services manually :). If using Laravel 5.5, you can use auto-discovery (add it to your composer.json), and if you're using Laravel 5.4 (or below), you can add your service provide to the config/app.php file.

That's all! Now you can write all the business logic into those wonderful services ;D.

Limitations

As useful as it might be, the package is pretty dumb: it just creates files based on some inputs and some predefined stubs. For that same reason, the package is very limited for now:

Changelog

-- No public version released yet --

Credits

Bugs & contributing

To-dos

License

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


All versions of service-generator with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/console Version 5.*
illuminate/support Version 5.*
illuminate/filesystem Version 5.*
okaybueno/validation Version 1.*
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 okaybueno/service-generator contains the following files

Loading the files please wait ....