1
votes

I need to put my zodiac package from vendor folder to packages folder in my root laravel directory in order to customize some data. Currently I made packages folder in root, cut my zodiac folder from vendor/intervetion and paste it in packages folder. Then in my composer.json I put code below.

composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "^6.5",
        "intervention/image": "^2.5",
        "intervention/zodiac": "dev-master",  // HERE I ADDED THIS!!!!!
        "laravel-notification-channels/messagebird": "^2.1",
        "laravel/framework": "^6.2",
        "laravel/socialite": "^4.3",
        "laravel/tinker": "^2.0",
        "laravel/ui": "^1.1",
        "predis/predis": "^1.1"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.2",
        "facade/ignition": "^1.4",
        "fzaninotto/faker": "^1.4",
        "jason-guru/laravel-make-repository": "^0.0.2",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^8.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "repositories": [
        {
            "type": "path",
            "url": "./packages/zodiac"  // HERE I ADDED THIS "repositories"!!!!!
        }
    ],
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

And after this when I hit composer update and composer dump-autoload, laravel makes new zodiac folder in vendor/intervetion folder and I am back on beggining. Any help is appreciated.

1
You can do this using custom filepaths, but as long as composer is controlling the dependency this will keep happening. If you want to edit the package you should download it manually.Simon Brahan
@SimonBrahan When I download it and put it in packages folder, what do I need to do to make it fully work then?mrmar

1 Answers

3
votes

In order to achieve that you just need to autoload the package by adding this line to your composer.json

"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Intervention\\Zodiac\\": "packages/zodiac/src/" <-- add this line
    },

and remove

"intervention/zodiac": "dev-master"

run command

composer dum

A better way to achieve whatyou need is forking the Intervention/zodiac repository to your github account, make changes there and then install your custom forked package.