Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use PR on GitHub for Laravel Packages?

When I want to make a pull request for a Laravel package on GitHub I do it at the moment in the following way:

  1. Create new Laravel project
  2. Require & install the package
  3. Delete the add-on files from the project in the vendor folder
  4. Fork GitHub and clone files into the project folder
  5. Make changes to package and test everything.
  6. Add, commit, push and do the pull request.

I find this a bit cumbersome - is that actually the correct way of doing it?

For example if I want create a PR for the voyager package I would have to do the following commands for step 1. & 2.

>laravel new create-pr
>cd create-pr
>composer require tcg/voyager
>php artisan voyager:install

then remove the folder tcg/voyager and clone the fork as new folder tcg/voyager.

If I skip composer require tcg/voyager and directly clone the fork into tcg/voyager I cant install the package because of

enter image description here

like image 209
Adam Avatar asked Sep 11 '25 16:09

Adam


1 Answers

First, fork the official repository tcg/voyager into your personal repository iwasherefirst2/voyager. Then

1) Create a new Laravel Project

2) Add repository iwasherefirst2/voyager to composer.json:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/iwasherefirst2/voyager.git"
    }
],

3) Now install tcg/voyager with --pref-source this will automatically install iwasherefirst2/voyager into vendor/tcg/voyager and setup the git connection.

composer require tcg/voyager --prefer-source

Now you may change files inside vendor/tcg/voyager and push them (they will be pushed to your local repository `iwasherefirst2/voyager).

Remarks

1) If you would like to have the package folder in the root of your application package/voyager, you may create a symlink like this:

ln -s vendor/tcg/voyager package

2) To see modified files in vendor you may call composer status -v

$ composer status -v
You have changes in the following dependencies:
/path/to/app/vendor/symfony/yaml/Symfony/Component/Yaml:
    M Dumper.php

3) If you run composer update you will get a warning if it overwrites any of your files

$ composer update
Loading composer repositories with package information
Updating dependencies
  - Updating symfony/symfony v2.2.0 (v2.2.0- => v2.2.0)
    The package has modified files:
    M Dumper.php
    Discard changes [y,n,v,s,?]?
like image 58
Adam Avatar answered Sep 13 '25 06:09

Adam