There is any full tutorial about laravel 5 package ?

Published 2 years ago by wowrudy

i need to build package for my apps for reuse in my other project.. i read laravel 5 docs about package but i still not understand..

i need full tutorial explain about package development by example like jeffrey do usually.. any link or recommendation what should i do ?

Best Answer (As Selected By wowrudy)
bestmomo

There are many starting points on github like this one or this one.

fahdgilani
martinbean

@wowrudy You would build a package like you would any other package. Have a look at other open source packages to see how their structure their code, tag it etc. Then, when you’ve written your package, pull it into your project via Composer.

wowrudy

@martinbean yes but i still confusing about workflow, what should i do at beginning until i can pull my project via composer

bestmomo
bestmomo
2 years ago (368,660 XP)

There are many starting points on github like this one or this one.

dazzz1er

@wowrudy I just made one for the first time and did it via making a new folder on my local file system, adding a composer.json to it and then adding these lines to my laravel project's composer.json I used to test the package:

"repositories": [
      {
         "type": "vcs",
         "url": "/path/to/new/package/folder"
      }
   ],
"require": {
        "packagename": "*"
}

and then you can just require your new package like any other (as above) and it will be pulled in from your local folder instead of packagist.

So for example all my projects are in a /Code directory, the new package is at /Code/package and my test Laravel 5 project pulling it in via composer is at /Code/testproject.

Annoyingly you must then composer update everytime you make a change, but you can create a symlink to skirt having to do that!

remailednet

From the composer docs: https://getcomposer.org/doc/05-repositories.md#path

You can also use composer's 'path' type repository

"repositories": [
        {
            "type": "path",
            "url": "packages/my-package"
        }
    ],
    "require": {
        "my/package": "*"
    }

You can also use wildcards:

 {
      "type": "path",
      "url": "packages/*"
 }

It will also attempt to symlink so you can skip the frequent 'composer update'.

sahadat5021

Sign In or create a forum account to participate in this discussion.