laravellaravel-9laravel-10github-packageslaravel-package

I am facing the issue with installation of the package


I have forked a Laravel drag and drop menu builder package from github pacakge name is efectn/laravel-menu-builder and I have changed the name of the package in the composer.json file with my name. Because the package https://github.com/efectn/laravel-menu-builder was not working on the Laravel 10 it was working on laravel 9 and after changing the name of the package in my github repo the package is not installing.

Like when I run the command composer require rah1595/laravel-drag-menu in my cmd to install this package in my laravel project I am getting an error

In PackageDiscoveryTrait.php line 368:

  Could not find a matching version of package rah1595/laravel-drag-menu. Check the package spelling, your version co
  nstraint and that the package is available in a stability which matches your minimum-stability (dev).

And when I am trying to install the package through the command c****omposer require rah1595/laravel-drag-menu:dev-master I am getting an error

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires rah1595/laravel-drag-menu, it could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

This is my composer Code

{
    "name": "rah1595/laravel-drag-menu",
    "description": "Wordpress like drag & drop menu builder for Laravel",
    "keywords": ["Laravel", "Menu", "Wordpress", "Builder", "Drag and Drop"],
    "authors": [
        {
            "name": "Rah",
            "email": "rah38951@gmail.com",
            "role": "Maintainer"
        },
        {
            "name": "Muhammed Efe Çetin",
            "email": "efectn@protonmail.com",
            "homepage": "https://6tel.net",
            "role": "Maintainer"
        },
        {
            "name": "Rendy Harimayco",
            "email": "rendyharimayco@gmail.com",
            "role": "Original Developer"
        },
        {
            "name": "Cristian Garcia",
            "email": "informacion@cristiangarcia.co",
            "role": "Original Developer"
        }
    ],
    "require": {
        "php": "^8.1",
        "illuminate/support": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0",
        "vendor/package": "1.1.1"
    },
    "autoload": {
        "psr-4": {
            "Efectn\\Menu\\": "src/"
        }
    },
    "extra": {
        "laravel": {
            "providers": [
                "Efectn\\Menu\\MenuServiceProvider"
            ],
            "aliases": {
                "Efectn": "Efectn\\Menu\\Facades\\Menu"
            }
        }
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/rah1595/laravel-drag-menu"
        }
    ],
    "minimum-stability": "dev",
    "prefer-stable": true
}

And this is my github package so that you can check it

rah1595/laravel-drag-menu

As I am trying to install the laravel package which I have forked from github the package name is efectn/laravel-menu-builder but I am unable to do as I have already explained above

I want to install it normally like other laravel package we install from the github


Solution

  • You're pretty close. The problem is that composer doesn't know where to look for to install your package. It searched in packagist by default, but couldn't find the package. You could follow the comments and publish it in packagist, but there's a much simpler way.

    To make it a lot simpler, you can give instructions to composer to look in a specific github repo to download this package instead of from packagist. This is possible by adding the repositories key in the composer.json of the project you are running composer require in and specifying it to look in your github repo. Here's a link to the documentation.

    So you can add the following to the composer.json of your project ( again, just reminding, this needs to be added to your project, not to the package )

    {
        "name": "my/project",
        "repositories": [
            {
                "type": "vcs",
                "url": "https://github.com/rah1595/laravel-drag-menu"
            }
        ],
        "require": {
            "php": "^8.1"
        },
        // Skipping rest
    }
    

    After adding this, composer require rah1595/laravel-drag-menu should work if everything is done correctly