Git Product home page Git Product logo

cmpsr.co's Introduction

Cmpsr

Cmpsr is an online bundler I made for composer.

Why?

When developing on my iPad Pro locally using DraftCode, I noticed it was very difficult because, although it supports offline PHP running, you cannot run composer commands to get packages from developers. To solve this, I built this application.

How it works

It works by generating a zipped vendor directory based on the composer file you give to it. Then when the generation is complete, it returns the hash and URL of the ZIP file. For now this works for me, though it has some limitations which could be addressed later.

You can see a sample fetcher script at cmpsr.php. Update this file and run it using a browser.

Installation

This project was built with Laravel and installation is similar. Nothing specific to have really. You just need your usual things:

  • An environment file (.env) with the correct database settings
  • Run composer install in the root of the project
  • Run php artisan migrate to migrate the database
  • Run php artisan storage:link to link the app/public dirctory to public/storage
  • Rename the public/storage directory to public/packages

Usage

To generate a package send a POST request to /install with data as the body of the request. The value of data should be the contents of the composer.json file. For example:

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://cmpsr.co/install",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"data\": \"{\\\"name\\\": \\\"neo\\/dumpr\\\",\\\"description\\\": \\\"a project\\\",\\\"require\\\":{\\\"symfony\\/var-dumper\\\": \\\"^4.3\\\"}}\"}",
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Content-Type: application/json",
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if (! $err) {
  echo $response;
}

Known limitations

I suspect this list will grow but for now, the known limitations are:

  • autoload.classmap is not supported
  • autoload.files is not supported
  • autoload-dev.classmap is not supported
  • autoload-dev.files is not supported

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

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.