laravel-custom-package-development

Custom Laravel Package Development

Share this post on:

Requirements :

  • Laravel v 5.5 or above is required.
  • Composer is installed on your system. You may get Composer here if you don’t already have it.

Step 1: Install the Laravel App

  • The first step is to construct a Laravel website. We’ll use Composer to set it up. Check out the official Laravel documentation for more installation options.

Step 2: Project Structure

  • PHP Composer is used to update dependencies and publish packages. A Composer is a tool for dependency management in PHP.
  • Before creating the composer.json file, create the below folders inside your Laravel project

Step 3: Create Composer File

  • Use the below command to generate composer.json
  • The composer.json file should now look like this.
  • Let us begin with autoloading the newly created package via the autoload block and add that code in composer.json.

Step 4: Adding Routes.php File

  • This will be accomplished by creating new routes.php in the package src dictionary, you can simply copy and paste the below-shown also.
  • After this include the routes.php file inside the boot() method of the service provider’s boot method.

Step 5: Add Package Service Provider

  • At the root of our app, let’s create our ServiceProvider with an artisan command via the command line.
  • After its process is completed, you’ll find a new file located at:
  • app/Providers/CustomServiceProvider.php
  • The next step will include moving this file into the package folder, the location will be:
  • packages/test/custom_package/src/CustomServiceProvider.php
  • Don’t miss out on changing your namespace to be:
  • Next, the last step of this pointer will be the addition of a new service provider in the large bracket – [] array mentioned in config/app.php:

Step 6: Create a Package controller

  • After its process is completed, you’ll find a new file located at:
  • app/Http/Controllers/CustomController.php
  • The next step will include moving this file into the package folder, The location will be:
  • packages/test/custom_package/src/CustomController.php
  • Now that we have created our controller, we will need to register it. Inside our Service Provider class in the register() method.
  • Finally, let’s add a few more routes to our routes.php file
  • Then, if we navigate to http://127.0.0.1:8000/add/4/4 and
    http:/127.0.0.1:8000//subtract/8/4 We end up with the following results!

Piyush Solanki

PHP Tech Lead & Backend Architect

10+ years experience
UK market specialist
Global brands & SMEs
Full-stack expertise

Core Technologies

PHP 95%
MySQL 90%
WordPress 92%
AWS 88%
  • Backend: PHP, MySQL, CodeIgniter, Laravel
  • CMS: WordPress customization & plugin development
  • APIs: RESTful design, microservices architecture
  • Frontend: React, TypeScript, modern admin panels
  • Cloud: AWS S3, Linux deployments
  • Integrations: Stripe, SMS/OTP gateways
  • Finance: Secure payment systems & compliance
  • Hospitality: Booking & reservation systems
  • Retail: E-commerce platforms & inventory
  • Consulting: Custom business solutions
  • Food Services: Delivery & ordering systems
  • Modernizing legacy systems for scalability
  • Building secure, high-performance products
  • Mobile-first API development
  • Agile collaboration with cross-functional teams
  • Focus on operational efficiency & innovation

Piyush is a seasoned PHP Tech Lead with 10+ years of experience architecting and delivering scalable web and mobile backend solutions for global brands and fast-growing SMEs.

He specializes in PHP, MySQL, CodeIgniter, WordPress, and custom API development, helping businesses modernize legacy systems and launch secure, high-performance digital products.

He collaborates closely with mobile teams building Android & iOS apps, developing RESTful APIs, cloud integrations, and secure payment systems. With extensive experience in the UK market and across multiple sectors, Piyush is passionate about helping SMEs scale technology teams and accelerate innovation through backend excellence.