3

I want to develope laravel package I have created sample project on github with a class. I use the package name from my github php package composer.json in my project composer.json in require{} array.

When I do composer update I get error. I need illustrative steps to develope and integrate PHP/Laravel package from using Github and composer.

Composer.json for project i am adding my package to, is :

    {
       "name": "laravel/laravel",
       "description": "The Laravel Framework.",
       "keywords": ["framework", "laravel"],
       "license": "MIT",
       "type": "project",
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "jeroen-g/laravel-packager": "^1.3",
    "igaster/laravel-theme": "^1.1",
    "laura/cms": "*.*"
},
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~4.0",
    "symfony/css-selector": "2.8.*|3.0.*",
    "symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
},
"scripts": {
    "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ],
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "pre-update-cmd": [
        "php artisan clear-compiled"
    ],
    "post-update-cmd": [
        "php artisan optimize"
    ]
},
"config": {
    "preferred-install": "dist"
},
"repositories": [{
    "type": "vcs",
    "url": "https://github.com/harish-php/lauracms"
}]

}

1 Answer 1

2

EDIT

Added some more explanation on how to create the custom package

Custom package composer.json

{
  
    "name": “packageName”,
  
    "autoload": {
    
        "psr-4": {
      
                “MySourcesNamespace\\”: "srcDir”
    
        }
  
    }

}

Composer.son of application

"require": {
   
    "packageName": "1.0.*"

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

The version here should be tagged. If you do not have a Tag you can depend on the master branch:

"require": {
   
    "MySourcesNamespace\\": "dev-master"

},

When doing composer update your classes should be inside the vendor directory.

Sign up to request clarification or add additional context in comments.

6 Comments

I did that..i am getting error about minimum stability..Will post detailed error message.
@harish Ok post the error message and the directory structure of your package
Your requirements could not be resolved to an installable set of packages. Problem 1 - The requested package laura/cms 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 <getcomposer.org/doc/04-schema.md#minimum-stability> for more details. Read <getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Ok a familiar error :). Can you post the composer.json where you are including the package?
Ok I gues to problem is here: "laura/cms": "*.*" Try changing it to "laura/cms": "dev-master" I saw on your github project you do not have any tags. So composer can't know what version to retrieve. Using dev-master tells composer to use the master branch. I have also edited my answer to include to necessary steps
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.