Zegnat / strapdown.php

Simple writing Markdown within HTML, inspired by Strapdown.js.
BSD Zero Clause License
0 stars 0 forks source link

Any way to include this via composer? #2

Open ScalaWilliam opened 7 years ago

ScalaWilliam commented 7 years ago

So I could use it say in my own website.

Zegnat commented 7 years ago

I don’t want to publish this on Packagist as it stands, a proof of concept, but you can still require this through Composer. The following composer.json file would require the latest version of this repository:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/Zegnat/strapdown.php"
        }
    ],
    "require" : {
        "zegnat/strapdown.php": "dev-master"
    }
}

Composer will make sure the executables of packages required are moved to ./vendor/bin. No need to go searching for strapdown in the vendor folder, just execute as ./vendor/bin/strapdown.

ScalaWilliam commented 7 years ago

Yes, this is what I was looking for (GitHub import) - and also if there's a way to call into the library from other PHP files. I'm quite new to Composer ;)

Zegnat commented 7 years ago

[…] I was looking for […] a way to call into the library from other PHP files

Two possibilities. You either use the executable through something like exec and its related functions, or you use the library.

To use the library you make sure your PHP includes Composer’s autoload.php file (require_once vendor/autoload.php) and it’ll make all of the libraries code available for use. If you need an example of how to use the Strapdown.php classes, just look at what the executable is doing.

Zegnat commented 7 years ago

Although I just realised method 1 might be broken, because the binary itself would be trying to include autoload.php from the wrong place. That needs looking into.