Using the littled lib Library in PHP Projects: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 22: Line 22:
== Installing composer ==
== Installing composer ==


Download the installer, which is a PHP script.
[https://getcomposer.org/download/ Download and install composer].
 
Install the libraries specified in `composer.json`.  


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ wget https://getcomposer.org/installer
$ php composer.phar install
</syntaxhighlight>
</syntaxhighlight>


Run the installer script.
Add the `--no-dev` option to skip over installing development dependencies:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ php -f ./installer
$ php composer.phar install --no-dev
</syntaxhighlight>
</syntaxhighlight>


Clean up the installer script.
== Making modifications on the library ==
 
Make sure to work on the `develop` branch of the repo.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ rm ./installer
$ git co develop
$ git pull origin develop
$ git push origin develop
</syntaxhighlight>
</syntaxhighlight>


Install the libraries specified in `composer.json`.  
`composer.json` is configured to look at that branch for updates. Any updates committed to `master` will be ignored.
 
== Downloading updates ==
 
From the directory containing the `composer.json` and `composer.phar` files:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ php composer.phar install
$ php composer.phar update
</syntaxhighlight>
</syntaxhighlight>


Add the `--no-dev` option to skip over installing development dependencies:
== Deployment ==


<syntaxhighlight lang="bash">
Copy `composer.json` to the staging/production server. The first time composer is run it will prompt for a token from GitHub. Use the link it provides to generate the token on GitHub, copy the token and paste it into the composer prompt to continue with the installation of the libraries. (The GitHub token is for the `littled_lib` hosted on GitHub, not for composer itself.)
$ php composer.phar install --no-dev
</syntaxhighlight>


== See also ==
== See also ==


* [https://getcomposer.org/doc/05-repositories.md#vcs Loading a Package from a VCS Repository] - Composer Documentation
* [https://getcomposer.org/doc/05-repositories.md#vcs Loading a Package from a VCS Repository] - Composer Documentation

Latest revision as of 12:25, 7 October 2018

Using composer[edit]

Add a composer.json file in the root of the PHP web project and configure it to fetch the littled_lib library from from GitHub.

{
  "require": {
    "php": ">=5.6.0",
    "ext-curl": "*",
    "dbarchowsky/littled": "dev-develop"
  },
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/dbarchowsky/littled_lib.git"
    }
  ]
}

Installing composer[edit]

Download and install composer.

Install the libraries specified in composer.json.

$ php composer.phar install

Add the --no-dev option to skip over installing development dependencies:

$ php composer.phar install --no-dev

Making modifications on the library[edit]

Make sure to work on the develop branch of the repo.

$ git co develop
$ git pull origin develop
$ git push origin develop

composer.json is configured to look at that branch for updates. Any updates committed to master will be ignored.

Downloading updates[edit]

From the directory containing the composer.json and composer.phar files:

$ php composer.phar update

Deployment[edit]

Copy composer.json to the staging/production server. The first time composer is run it will prompt for a token from GitHub. Use the link it provides to generate the token on GitHub, copy the token and paste it into the composer prompt to continue with the installation of the libraries. (The GitHub token is for the littled_lib hosted on GitHub, not for composer itself.)

See also[edit]