{"id":20903521,"url":"https://github.com/phly/phlypaste","last_synced_at":"2025-05-13T04:33:19.373Z","repository":{"id":5086457,"uuid":"6248769","full_name":"phly/PhlyPaste","owner":"phly","description":"Pastebin module for ZF2 applications","archived":false,"fork":false,"pushed_at":"2012-12-13T12:26:49.000Z","size":244,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T18:12:08.049Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ericdrowell/KineticJS","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-16T18:01:35.000Z","updated_at":"2015-06-14T07:22:03.000Z","dependencies_parsed_at":"2022-08-23T23:31:03.951Z","dependency_job_id":null,"html_url":"https://github.com/phly/PhlyPaste","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phly%2FPhlyPaste","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phly%2FPhlyPaste/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phly%2FPhlyPaste/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phly%2FPhlyPaste/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phly","download_url":"https://codeload.github.com/phly/PhlyPaste/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253877265,"owners_count":21977632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T13:13:56.636Z","updated_at":"2025-05-13T04:33:18.065Z","avatar_url":"https://github.com/phly.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PhlyPaste - ZF2 Pastebin Module\n===============================\n\nThis is a module implementing a ZF2 pastebin.\n\nFeatures\n--------\n\n- Normal pastebin features: syntax highlighting by language, short URLs, ability\n  to mark pastes as \"private\" (meaning they do not show up in listings).\n- Ability to specify \"markdown\" as the language; this will pass the paste\n  through the markdown parser to generate markup.\n- Ability to specify \"sections\" of code, and thus paste multiple \"files\" in the\n  same paste. Any line starting with \"##\" signifies a section. The section will\n  contain any text following \"##\" as the title:\n\n    ## test.txt\n    This is the first section.\n\n    ## test2.txt\n    This is the second section.\n\n  Additionally, if you place a language name in brackets, that language will be\n  used for syntax highlighting for that section:\n\n    ## test.js [javascript]\n    {\n        \"text\": \"highlighted as javascript\"\n    }\n\n    ## test.php [php]\n    echo \"This is highlighted as PHP\";\n\n  Developers familiar with pastie.org will find the above syntax familiar.\n- An API for listing pastes, retrieving individual paste details, and submitting\n  pastes. The paste retrieval portion of the API does not require authorization,\n  but submitting a paste requires an authorization token. (See the section\n  titled \"API\" below for details.\n\nInstallation\n------------\n\nInstall via composer:\n\n```javascript\n{\n    \"minimum-stability\": \"dev\",\n    \"repositories\": [\n        {\n            \"type\": \"composer\",\n            \"url\": \"http://packages.zendframework.com/\"\n        }\n    ],\n    \"require\": {\n        \"phly/phly-paste\": \"dev-master\"\n    }\n}\n```\n\nTo allow Markdown as a type of markup, you'll also need to install\n`EdpMarkdown`. This can be done with the following:\n\n```bash\ncd vendor\ngit clone --recursive git://github.com/EvanDotPro/EdpMarkdown.git\n```\n\nNext, add `EdpMarkdown` to your modules array in `config/application.config.php`.\n\nMongo Usage\n-----------\n\nTo use Mongo as a backend, you will need to do several things.\n\nFirst, add \"phly/phly-mongo\" as a `composer.json` requirement:\n\n```javascript\n{\n    \"minimum-stability\": \"dev\"\n    \"require\": {\n        \"phly/phly-paste\": \"dev-master\",\n        \"phly/phly-mongo\": \"dev-master\"\n    }\n}\n```\n\nAfter running `php composer.phar update`, you'll also need to configure your\napplication to use Mongo. One easy way to do this is in your site's primary\nmodule (usually \"Application\"):\n\n```php\nnamespace Application;\n\nuse PhlyMongo\\MongoDbFactory;\nuse PhlyMongo\\MongoCollectionFactory;\nuse PhlyPaste\\MongoPasteService;\n\nclass Module\n{\n    public function getServiceConfig()\n    {\n        return array('factories' =\u003e array(\n           'Paste\\Mongo'           =\u003e 'PhlyMongo\\MongoConnectionFactory',\n           'Paste\\MongoDb'         =\u003e new MongoDbFactory('site', 'Paste\\Mongo'),\n           'Paste\\MongoCollection' =\u003e new MongoCollectionFactory('pastes', 'Paste\\MongoDb'),\n           'PhlyPaste\\MongoService' =\u003e function ($services) {\n               $collection = $services-\u003eget('Paste\\MongoCollection');\n               return new MongoPasteService($collection);\n           },\n        ));\n    }\n}\n```\n\nAlternately, you can simply configure a service returning a `MongoCollection`, \nand pass that to the `MongoPasteService` constructor.\n\nMake sure to create indices on each of the \"hash\" and \"timestamp\" fields:\n\n```php\n// Create a unique index on the \"hash\" field\n$collection-\u003eensureIndex(array('hash' =\u003e 1), array('unique' =\u003e true));\n\n// Create an index on \"timestamp\" descending\n$collection-\u003eensureIndex(array('timestamp' =\u003e -1));\n```\n\nYou can do the above in your factory, if desired.\n\nZend\\Db\\TableGateway Usage\n--------------------------\n\nCurrently, only SQLite is supported. To set up your database, do the following\nfrom your application root:\n\n```bash\nsqlite data/paste.db \u003c vendor/phly/phly-paste/config/schema.sqlite.sql\n```\n\nMake sure the `data/paste.db` file is writeable by your webserver.\n\nThen create the following configuration in your `config/autoload/global.php`\nfile (or some other autoloadable configuration file in that directory):\n\n```php\nreturn array(\n    'db' =\u003e array(\n        'driver' =\u003e 'Pdo',\n        'dsn'    =\u003e 'sqlite:' . getcwd() . '/data/paste.db',\n    ),\n    'service_manager' =\u003e array(\n        'aliases' =\u003e array(\n            'PhlyPaste\\PasteService' =\u003e 'PhlyPaste\\TableGatewayService',\n        ),\n        'factories' =\u003e array(\n            'Zend\\Db\\Adapter\\Adapter' =\u003e 'Zend\\Db\\Adapter\\AdapterServiceFactory',\n        ),\n    ),\n);\n```\n\nOnce this is in place, you should be able to create and lists pastes.\n\nCAPTCHA setup\n-------------\n\nBy default, the \"Dumb\" CAPTCHA adapter is used. You can setup an alternate one\nby providing either global or local configuration under the \"phly_paste\" key's\n\"captcha\" subkey. Configuration is consistent with `Zend\\Captcha\\Factory`:\n\n```php\nreturn array(\n    'phly_paste' =\u003e array(\n        'captcha' =\u003e array(\n            'class' =\u003e 'CaptchaClassName',\n            'options' =\u003e array(/* array of adapter-specific options */),\n        ),\n    ),\n);\n```\n\nYou can disable CAPTCHA for authenticated users. To do this, you need to define\nan alias named `PhlyPaste\\AuthService` that points to a service returning a\n`Zend\\Authentication\\AuthenticationService` instance. Once enabled, CAPTCHAs\nwill no longer be displayed for currently authenticated users.\n\nAPI\n---\n\nAn API is also enabled for this module. By default, it goes to the route\ndescribed by the path '/paste/api/paste'. The API is JSON only, and expects that\nthe Accept header matches against the media type 'application/hal+json' (it also\nallows 'application/json', but 'application/hal+json' will always be returned). \n\nThe following operations are available:\n\n### GET /paste/api/paste[?page=X]\n\n\nRetrieves a single page of a list of pastes. The payload looks like the\nfollowing:\n\n    HTTP/1.0 200 Ok\n    Content-Type: application/json\n\n    {\n        \"_links\": {\n            \"canonical\": {\"rel\": \"canonical\", \"href\": \"http://pages.local/paste\"},\n            \"self\": {\"rel\": \"self\", \"href\": \"http://pages.local/paste/api/paste\"},\n            \"first\": {\"rel\": \"first\", \"href\": \"http://pages.local/paste/api/paste\"},\n            \"last\": {\"rel\": \"last\", \"href\": \"http://pages.local/paste/api/paste?page=X\"},\n            \"next\": {\"rel\": \"next\", \"href\": \"http://pages.local/paste/api/paste?page=2\"}\n        },\n        \"items\": [\n            [\n                {\"rel\": \"canonical\", \"href\": \"http://pages.local/paste/XYZ\"},\n                {\"rel\": \"item\", \"href\": \"http://pages.local/paste/api/paste/XYZ\"}\n            ],\n            /* ... */\n        ]\n    }\n\n### GET /paste/api/paste/XYZ12ABC\n\nFetches information on a single paste. The payload looks like the following:\n\n    HTTP/1.0 200 Ok\n    Content-Type: application/json\n\n    {\n        \"_links\": {\n            \"canonical\": {\"rel\": \"canonical\", \"href\": \"http://pages.local/paste/XYZ12ABC\"},\n            \"self\": {\"rel\": \"self\", \"href\": \"http://pages.local/paste/api/paste/XYZ12ABC\"},\n            \"up\": {\"rel\": \"up\", \"href\": \"http://pages.local/paste/api/paste\"}\n        },\n        \"title\": \"...\",\n        \"language\": \"...\",\n        \"timestamp\": \"...\",\n    }\n\n### POST /paste/api/paste\n\nExpects a JSON body, like the following:\n\n    Accept: application/json\n    Content-Type: application/json\n    X-PhlyPaste-Token: yourtoken\n\n    {\n        \"language\": \"txt\",\n        \"private\": \"false\",\n        \"content\": \"This is the paste content...\"\n    }\n\nYou will get the following response payload:\n\n    HTTP/1.0 201 Created\n    Location: http://paste.local/paste/XYZ12ABC\n    Content-Type: application/json\n\n    {\n        \"_links\": {\n            \"canonical\": {\"rel\": \"canonical\", \"href\": \"http://pages.local/paste/XYZ12ABC\"},\n            \"self\": {\"rel\": \"self\", \"href\": \"http://pages.local/paste/api/paste/XYZ12ABC\"}\n        }\n    }\n\n### Authorization Tokens for Submitting Pastes\n\nAs you may have noticed in the previous example, the POST operation requires an\n\"X-PhlyPaste-Token\" header. Tokens are verified against the\n`PhlyPaste\\TokenService` service, which is simply a\n`PhlyPaste\\Model\\TokenServiceInterface` implementation. By default, a single\nimplementation is provided, `PhlyPaste\\Model\\ArrayTokenService`. This\nimplementation expects that the configuration includes tokens:\n\n```php\nreturn array(\n    'phly_paste' =\u003e array(\n        'tokens' =\u003e array(\n            'yourtoken',\n        ),\n    ),\n);\n```\n\nIf you use this approach, make sure that tokens are defined in `.local.php`\nfiles that are stored outside your repository.\n\nAlternately, you may create your own implementation of the\n`TokenServiceInterface` that can be used to verify tokens.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphly%2Fphlypaste","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphly%2Fphlypaste","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphly%2Fphlypaste/lists"}