{"action":"created","issue":{"url":"https://api.github.com/repos/infostreams/snippets/issues/2","labels_url":"https://api.github.com/repos/infostreams/snippets/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/infostreams/snippets/issues/2/comments","events_url":"https://api.github.com/repos/infostreams/snippets/issues/2/events","html_url":"https://github.com/infostreams/snippets/issues/2","id":69964130,"number":2,"title":"Snippets not working","user":{"login":"bricebou","id":1000213,"avatar_url":"https://avatars.githubusercontent.com/u/1000213?v=3","gravatar_id":"","url":"https://api.github.com/users/bricebou","html_url":"https://github.com/bricebou","followers_url":"https://api.github.com/users/bricebou/followers","following_url":"https://api.github.com/users/bricebou/following{/other_user}","gists_url":"https://api.github.com/users/bricebou/gists{/gist_id}","starred_url":"https://api.github.com/users/bricebou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bricebou/subscriptions","organizations_url":"https://api.github.com/users/bricebou/orgs","repos_url":"https://api.github.com/users/bricebou/repos","events_url":"https://api.github.com/users/bricebou/events{/privacy}","received_events_url":"https://api.github.com/users/bricebou/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-04-21T22:07:41Z","updated_at":"2015-04-23T09:37:29Z","closed_at":"2015-04-23T09:37:29Z","body":"Hi,\r\n\r\nI'm trying to set up a small new project using Phile in which I have to display an audio player. I tried to use your plugin but I can't make it work and I have no errors from Phile.\r\n\r\nI'm working locally (on a Xubuntu up to date). I've just installed Phile using composer \r\n```\r\ncomposer create-project --no-dev phile-cms/phile\r\n```\r\n\r\nI've installed your plugin using composer:\r\n```\r\ncomposer require infostreams/snippets:*\r\n```\r\nand updated my config file plugin section:\r\n```\r\n$config['plugins'] = array(\r\n\t'infostreams\\\\snippets' => array('active' => true)\r\n);\r\n```\r\n\r\nIn a content index.md when I try to use \r\n```\r\n(youtube: http://www.youtube.com/watch?v=mSB71jNq-yQ)\r\n\r\n(youtube: https://www.youtube.com/watch?v=mSB71jNq-yQ width:640)\r\n\r\n(link: cnn.com)\r\n\r\n(file: Catherine_awards.xls text:our brochure)\r\n```\r\nI only got the same, I mean it isn't parse.\r\n\r\nI've tried to deactivate the cache from the default config but without success ; here is the plugin section from the default:\r\n```\r\n$config['plugins'] = array(\r\n\t// key = vendor\\\\pluginName (vendor lowercase, pluginName lowerCamelCase\r\n\t'mycompany\\\\demoPlugin'            => array('active' => false),\r\n\t'phile\\\\errorHandler'              => array(\r\n\t\t'active' => true,\r\n\t\t'handler' => \\Phile\\Plugin\\Phile\\ErrorHandler\\Plugin::HANDLER_DEVELOPMENT\r\n\t), // the default error handler\r\n\t'phile\\\\parserMarkdown'            => array('active' => true), // the default parser\r\n\t'phile\\\\parserMeta'                => array('active' => true), // the default parser\r\n\t'phile\\\\templateTwig'              => array('active' => true), // the default template engine\r\n\t'phile\\\\phpFastCache'              => array('active' => false), // the default cache engine\r\n\t'phile\\\\simpleFileDataPersistence' => array('active' => false), // the default data storage engine\r\n);\r\n```\r\nI've tried to use the Github version but without success.\r\n\r\nIt seems I have the 1.5.0 version of Phile (from the Changelog) and here is my composer.json if it can help:\r\n```\r\n{\r\n    \"name\": \"phile-cms/phile\",\r\n    \"type\": \"project\",\r\n    \"description\": \"A file-based CMS with a swappable parser, template engine, cache and storage services, error handler, and meta parser.\",\r\n    \"keywords\": [\"cms\", \"markdown\", \"flat\", \"file\", \"twig\", \"plugins\"],\r\n    \"homepage\": \"http://philecms.com\",\r\n    \"license\": \"MIT\",\r\n    \"authors\": [\r\n        {\r\n            \"name\": \"Frank Nägler\",\r\n            \"email\": \"mail@naegler.net\",\r\n            \"homepage\": \"http://www.frank-naegler.de\",\r\n            \"role\": \"Developer\"\r\n        },\r\n        {\r\n            \"name\": \"James Doyle\",\r\n            \"email\": \"james2doyle@gmail.com\",\r\n            \"homepage\": \"http://ohdoylerules.com/\",\r\n            \"role\": \"Developer\"\r\n        },\r\n        {\r\n            \"name\": \"Schlaefer\",\r\n            \"email\": \"openmail+sourcecode@siezi.com\",\r\n            \"homepage\": \"http://siezi.com/\",\r\n            \"role\": \"Developer\"\r\n        }\r\n    ],\r\n    \"config\": {\r\n        \"vendor-dir\": \"lib/vendor\"\r\n    },\r\n    \"require\": {\r\n        \"php\": \">=5.4.0\",\r\n        \"twig/twig\": \"1.15.*\",\r\n        \"michelf/php-markdown\": \">=1.4\",\r\n        \"phpfastcache/phpfastcache\": \"~3.0\",\r\n        \"phile-cms/plugin-installer-plugin\": \">=1.0.2\",\r\n        \"gibbs/phile-sub-navigation\": \"1.*\",\r\n        \"infostreams/snippets\": \"*\"\r\n    },\r\n    \"require-dev\": {\r\n        \"phpdocumentor/phpdocumentor\": \"2.6.*\",\r\n        \"phing/phing\": \"2.*\",\r\n        \"phpunit/phpunit\": \"*\"\r\n    }\r\n}\r\n```\r\n\r\nThanks in advance.\r\n"},"comment":{"url":"https://api.github.com/repos/infostreams/snippets/issues/comments/95512554","html_url":"https://github.com/infostreams/snippets/issues/2#issuecomment-95512554","issue_url":"https://api.github.com/repos/infostreams/snippets/issues/2","id":95512554,"user":{"login":"infostreams","id":1132744,"avatar_url":"https://avatars.githubusercontent.com/u/1132744?v=3","gravatar_id":"","url":"https://api.github.com/users/infostreams","html_url":"https://github.com/infostreams","followers_url":"https://api.github.com/users/infostreams/followers","following_url":"https://api.github.com/users/infostreams/following{/other_user}","gists_url":"https://api.github.com/users/infostreams/gists{/gist_id}","starred_url":"https://api.github.com/users/infostreams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infostreams/subscriptions","organizations_url":"https://api.github.com/users/infostreams/orgs","repos_url":"https://api.github.com/users/infostreams/repos","events_url":"https://api.github.com/users/infostreams/events{/privacy}","received_events_url":"https://api.github.com/users/infostreams/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T09:37:29Z","updated_at":"2015-04-23T09:37:29Z","body":"We're not really talking about the bug anymore, but I'll allow it for now (and then close this ticket).\r\n\r\nRegarding where to put your Snippets class - you can either do a `require_once('<somefolder>/MySnippets.php');` in your `index.php` or `config.php`, but that's pretty dirty. Instead, you should probably follow this procedure to have it autoloaded like the rest of Phile:\r\n\r\n0. First, think of a name (a single word) for the namespace. Use your own name, or your company name, or the name of your site. In this example I use `mynamespace`. Replace any occurrences with the name you've chosen.\r\n1. Update your `composer.json` to include the following (put it at the end of the file, directly after `require` or `require-dev`):\r\n\r\n    ```json \r\n    \"autoload\": {\r\n        \"psr-0\": {\r\n            \"<mynamespace>\": \"src/\"\r\n        }\r\n    }\r\n```\r\n\r\n    My `composer.json` now reads something like:\r\n\r\n    ```json\r\n    \"require\": {\r\n        \"php\": \">=5.4.0\",\r\n        \"twig/twig\": \"1.15.*\",\r\n        \"michelf/php-markdown\": \">=1.4\",\r\n        \"phpfastcache/phpfastcache\": \"~3.0\",\r\n        \"phile-cms/plugin-installer-plugin\": \">=1.0.2\",\r\n        \"infostreams/snippets\": \"1.*\"\r\n    },\r\n    \"require-dev\": {\r\n        \"phpdocumentor/phpdocumentor\": \"2.6.*\",\r\n        \"phing/phing\": \"2.*\",\r\n        \"phpunit/phpunit\": \"*\"\r\n    },\r\n    \"autoload\": {\r\n        \"psr-0\": {\r\n            \"mynamespace\": \"src/\"\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n3. Run `composer update` (or equivalent) to have composer generate a new autoloader\r\n4. Open `lib/vendor/composer/autoload_namespaces.php` and check if it contains an entry for `<mynamespace>`\r\n5. If it does, create a directory named `src` in the root of your site, relative to where `composer.json` is. You can obviously name this directory anything you want, but I went with 'src'.\r\n6. In that directory, create a new directory named `<mynamespace>`. \r\n7. Add a file called `MySnippets.php` to the `src/<mynamespace>/` directory. Put the following contents in that file:\r\n\r\n    ```php\r\n<?php\r\nnamespace mynamespace;\r\n\r\nclass MySnippets extends \\Phile\\Plugin\\Infostreams\\Snippets\\Snippets {\r\n\tpublic function skype($name, $action=\"call\", $text=null) {\r\n\t\tif (is_null($text)) {\r\n\t\t\t$text = \"Contact '$name' on Skype\";\r\n\t\t}\r\n\t\treturn \"<a href='skype:$name?$action'>$text</a>\";\r\n\t}\r\n\r\n\tpublic function facebook($who, $attribute, $other_attribute) {\r\n\t\t// ...\r\n\t}\r\n\r\n\tpublic function scroller($pictures) {\r\n\t\t// ...\r\n\t}\r\n\r\n\tpublic function youtube_popup($link) {\r\n\t\t// ...\r\n\t}\r\n}\r\n```\r\n8. Finally, in your site's `config.php`, add the following code:\r\n\r\n    ```php\r\n$config['plugins']['infostreams\\\\snippets']['snippets'] = array(\r\n\tnew \\mynamespace\\MySnippets()\r\n);\r\n```\r\n\r\n9. That should do it! You can now define your own snippets in the `MySnippets` class. If it doesn't work, read up on the Composer autoloader, for example [here](https://jtreminio.com/2012/10/composer-namespaces-in-5-minutes/).\r\n\r\nRegarding your other two questions: you can get the base URL with `(new Router)->getBaseUrl()` and the current URL with `(new Router)->getCurrentUrl()` - but since your original issue is resolved and these are basically questions about Phile itself I will now close this question. \r\n\r\nHappy hacking!\r\n\r\nEd"}}