Download the PHP package macerd/laravel-package-tools without Composer

On this page you can find all versions of the php package macerd/laravel-package-tools. 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-package-tools

Tools for creating Laravel packages

Latest Version on Packagist Tests Total Downloads

This package contains a PackageServiceProvider that you can use in your packages to easily register config files, migrations, and more.

Here's an example of how it can be used.

Under the hood it will do the necessary work to register the necessary things and make all sorts of files publishable.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Getting started

This package is opinionated on how you should structure your package. To get started easily, consider using our package-skeleton repo to start your package. The skeleton is structured perfectly to work perfectly with the PackageServiceProvider in this package.

Usage

In your package you should let your service provider extend Spatie\LaravelPackageTools\PackageServiceProvider.

Passing the package name to name is mandatory.

Working with a config file

To register a config file, you should create a php file with your package name in the config directory of your package. In this example it should be at <package root>/config/your-package-name.php.

If your package name starts with laravel-, we expect that your config file does not contain that prefix. So if your package name is laravel-cool-package, the config file should be named cool-package.php.

To register that config file, call hasConfigFile() on $package in the configurePackage method.

The hasConfigFile method will also make the config file publishable. Users of your package will be able to publish the config file with this command.

Should your package have multiple config files, you can pass their names as an array to hasConfigFile

Working with views

Any views your package provides, should be placed in the <package root>/resources/views directory.

You can register these views with the hasViews command.

This will register your views with Laravel.

If you have a view <package root>/resources/views/myView.blade.php, you can use it like this: view('your-package-name::myView'). Of course, you can also use subdirectories to organise your views. A view located at <package root>/resources/views/subdirectory/myOtherView.blade.php can be used with view('your-package-name::subdirectory.myOtherView').

Using a custom view namespace

You can pass a custom view namespace to the hasViews method.

You can now use the views of the package like this:

Publishing the views

Calling hasViews will also make views publishable. Users of your package will be able to publish the views with this command:

Sharing global data with views

You can share data with all views using the sharesDataWithAllViews method. This will make the shared variable available to all views.

Working with Blade view components

Any Blade view components that your package provides should be placed in the <package root>/src/Components directory.

You can register these views with the hasViewComponents command.

This will register your view components with Laravel. In the case of Alert::class, it can be referenced in views as <x-spatie-alert />, where spatie is the prefix you provided during registration.

Calling hasViewComponents will also make view components publishable, and will be published to app/Views/Components/vendor/<package name>.

Users of your package will be able to publish the view components with this command:

Working with view composers

You can register any view composers that your project uses with the hasViewComposers method. You may also register a callback that receives a $view argument instead of a classname.

To register a view composer with all views, use an asterisk as the view name '*'.

Working with translations

Any translations your package provides, should be placed in the <package root>/resources/lang/<language-code> directory.

You can register these translations with the hasTranslations command.

This will register the translations with Laravel.

Assuming you save this translation file at <package root>/resources/lang/en/translations.php...

... your package and users will be able to retrieve the translation with:

If your package name starts with laravel- then you should leave that off in the example above.

Coding with translation strings as keys, you should create JSON files in <package root>/resources/lang/<language-code>.json.

For example, creating <package root>/resources/lang/it.json file like so:

...the output of...

...will be Ciao! if the application uses the Italian language.

Calling hasTranslations will also make translations publishable. Users of your package will be able to publish the translations with this command:

Working with assets

Any assets your package provides, should be placed in the <package root>/resources/dist/ directory.

You can make these assets publishable the hasAssets method.

Users of your package will be able to publish the assets with this command:

This will copy over the assets to the public/vendor/<your-package-name> directory in the app where your package is installed in.

Working with migrations

The PackageServiceProvider assumes that any migrations are placed in this directory: <package root>/database/migrations. Inside that directory you can put any migrations.

To register your migration, you should pass its name without the extension to the hasMigration table.

If your migration file is called create_my_package_tables.php.stub you can register them like this:

Should your package contain multiple migration files, you can just call hasMigration multiple times or use hasMigrations.

Calling hasMigration will also make migrations publishable. Users of your package will be able to publish the migrations with this command:

Like you might expect, published migration files will be prefixed with the current datetime.

Registering commands

You can register any command you package provides with the hasCommand function.

`

If your package provides multiple commands, you can either use hasCommand multiple times, or pass an array to hasCommands

Working with routes

The PackageServiceProvider assumes that any route files are placed in this directory: <package root>/routes. Inside that directory you can put any route files.

To register your route, you should pass its name without the extension to the hasRoute method.

If your route file is called web.php you can register them like this:

Should your package contain multiple route files, you can just call hasRoute multiple times or use hasRoutes.

Using lifecycle hooks

You can put any custom logic your package needs while starting up in one of these methods:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of laravel-package-tools with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
illuminate/contracts Version ^7.0|^8.0|^9.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 macerd/laravel-package-tools contains the following files

Loading the files please wait ....