How to develop package into Laravel ?

Laravel
January 27, 20211 minuteuserVishal Ribdiya
How to develop package into Laravel ?

In our daily life, we are going through lots of packages, and some of us don't know how to build our own package into Laravel.

We are going to perform the core steps to create your own package in laravel. In this tutorial we are going to build a zoom package, so we will perform steps related to it.

Setup Fresh Laravel Repo

Setup fresh laravel repo, and then create directories within it.

for e.g Create infyomlabs/zoom-api directory into the root.

2021-01-23-600c1615b8dc5

Now create src directory into zoom-api

Run Composer init Into src Directory

After hitting composer init it will ask for some information from you, as you can see below image I have entered some of the information. you can just hit enter if you do not want to add other information.

2021-01-23-600c1880b29e5

Add your config file (Optional)

Create a directory config into the src directory and add your config.php file there from where you can manage your env variables.

2021-01-23-600c195f8a4e3

Add Service Provider

Create your service provider from where you can do lots of actions. like you can publish config/routes/ migrations files from there. Here we are publishing the zoom config file.

2021-01-23-600c1aaf5a24d

Add your class (Which contains all functions)

Here we have added a Zoom class which will contain all zoom functions.

2021-01-23-600c1b713c011

Update Composer.json

2021-01-23-600c1cbe97ce6

Finally, Test it in your existing project

Put the following code to your main composer.json (in your project's root). and hit composer update

  "repositories": [
        {
            "type": "path",
            "url": "infyomlabs/zoom-api",
            "options": {
                "symlink": true
            }
        }
    ],
    "license": "MIT",
    "require": {
        "infyomlabs/zoom-api": "dev-develop"
    },