laravel-custom-package-development

200OK Solutions Blog | Insights & Tutorials

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!

BlogAdmin

Digital Transformation Counsultant (Public Sector)

25+ years experience
UK public sector & enterprise specialist
Board-level commercial leadership
Technology & consultancy expertise

Core Technologies

Business Development 95%
Digital Transformation 92%
Public Sector Solutions 90%
Cloud & AWS Partnerships 85%
  • Public Sector: Government & enterprise solution engagement
  • Commercial: Consultative business development, stakeholder management
  • Technology: Digital services, cloud-led transformation solutions
  • Leadership: Board-level advisory, operational efficiency & innovation
  • Backend: Business transformation strategy, programme delivery, solution consulting
  • Public Sector
  • Enterprise Technology
  • Consulting & Advisory
  • Programme Delivery
  • Cloud & Digital Services
  • Solving complex business challanges through technology-led innovaion
  • Combining consultancy, and delivery expertise
  • Building long-term partnershipis across enterprise & government sectors
  • Driving transformation with practical, outcome-focused solutions
  • Aligning technology investments with operational and commercial goals

BlogAdmin is an experienced digital transformation leader (public sector) with a strong track record of helping organizations solve complex operational and technology challanges through innovative commercial and technical solutions.

With extensive experience spanning consultancy, programme delivery, cloud partnerships, and strategic business dvelopment, he has worked across multiple sectors including public sector, enterprise technology, and digital services.

He brings a rare combinatioin of board-level commercial leadership and hands-on delivery understanding, enabling him to bridge the gap between business objectives and technology execution.

BlogAdmin is paricularly experienced in consultative selling, AWS partnership ecosystems, public sector engagement, and designing commercially viable transformation strategies that combine technology, services and operational efficiency.

Known for his ability to thinik differently around business challanges, he focuses on creating scalable, innovative solutions that help organizations modernize operations, improve service delivery, and accelarate digital transformation initiatives.

    Reach Out Us


    Your name

    Your email

    Subject

    Your message