GithubHelp home page GithubHelp logo

tobias2k / composer-wrapper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eviweb/composer-wrapper

0.0 0.0 0.0 97 KB

Allows the use of composer from within a script, even if it is not installed.

License: MIT License

PHP 100.00%

composer-wrapper's Introduction

Composer Wrapper

This project aims to provide a way to use composer from within a script, even if it is not installed.

Build Status

How to install :

You can choose between :

  1. clone this repo git clone https://github.com/eviweb/composer-wrapper.git
  2. use composer by adding "eviweb/composer-wrapper" : "1.*" to the require section of your composer.json
  3. directly download the Wrapper.php
  4. dynamic install see below

How to use :

Include the wrapper

First, you need to include the wrapper into your code, according to the previous installation choice :

  1. add ``` require_once 'PATH_TO_COMPOSER_WRAPPER_DIRECTORY/src/evidev/composer/Wrapper.php';
2.    add ```
require 'vendor/autoload.php';
``` please refer to the [Composer Documentation](http://getcomposer.org/doc/00-intro.md#autoloading)    
3.    add ```
require_once 'PATH_TO_COMPOSER_WRAPPER_FILE';
``` where _PATH_TO_COMPOSER_WRAPPER_FILE_ is the path to the _Wrapper.php_ file    
4.    add    
    
>        $wrapper_file = sys_get_temp_dir() . '/Wrapper.php';
>        if (!file_exists($wrapper_file)) {
>             file_put_contents(
>                 $wrapper_file,
>                 file_get_contents('https://raw.github.com/eviweb/composer-wrapper/master/src/evidev/composer/Wrapper.php')
>             );
>        }
>        require_once $wrapper_file;    
     
     
### Use the wrapper
1.    for a command line use, simply add ```exit(\evidev\composer\Wrapper::create()->run());``` to your executable script    
2.    if you want to use it in the body of your script, and pass specific arguments to the _Wrapper::run()_ method you need to do as the following :    
    
>        $wc = \evidev\composer\Wrapper::create();
>        $exit_code = $wc->run("COMPOSER_OPTION_OR_COMMAND_AS_STRING");
>        // add more code here for example
>        exit($exit_code);    
     
where _COMPOSER_OPTION_OR_COMMAND_AS_STRING_ is a composer option or command
     
### How it works    
The Wrapper downloads the ```composer.phar``` file when created.    
By default the ```composer.phar``` is downloaded in ```sys_get_temp_dir()```, but you can specify a target directory 
by passing its path as a parameter of ```Wrapper::create()```.    
If this parameter is an empty string or if the directory does not exist, ```sys_get_temp_dir()``` is used as fallback    
In case of use of many instances of the Wrapper, created with different directories _(which should never happened)_, 
the first downloaded ```composer.phar``` is used.    

composer-wrapper's People

Contributors

eviweb avatar tobias2k avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.