{"action":"closed","issue":{"url":"https://api.github.com/repos/dingo/api/issues/347","labels_url":"https://api.github.com/repos/dingo/api/issues/347/labels{/name}","comments_url":"https://api.github.com/repos/dingo/api/issues/347/comments","events_url":"https://api.github.com/repos/dingo/api/issues/347/events","html_url":"https://github.com/dingo/api/issues/347","id":55452852,"number":347,"title":"Custom Package Route - Call to undefined method Illuminate\\Routing\\Router::api()","user":{"login":"CreativityKills","id":807318,"avatar_url":"https://avatars.githubusercontent.com/u/807318?v=3","gravatar_id":"","url":"https://api.github.com/users/CreativityKills","html_url":"https://github.com/CreativityKills","followers_url":"https://api.github.com/users/CreativityKills/followers","following_url":"https://api.github.com/users/CreativityKills/following{/other_user}","gists_url":"https://api.github.com/users/CreativityKills/gists{/gist_id}","starred_url":"https://api.github.com/users/CreativityKills/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CreativityKills/subscriptions","organizations_url":"https://api.github.com/users/CreativityKills/orgs","repos_url":"https://api.github.com/users/CreativityKills/repos","events_url":"https://api.github.com/users/CreativityKills/events{/privacy}","received_events_url":"https://api.github.com/users/CreativityKills/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-26T07:17:10Z","updated_at":"2015-01-26T07:21:44Z","closed_at":"2015-01-26T07:21:44Z","body":"When creating a custom package and you are including the `routes.php` file of **that package** in the boot or register method of the service provider, that error comes up. If i move the route definitions to the default `routes.php` file in the app directory i get no issues.\r\n\r\n```\r\n-- app/\r\n---- commands\r\n---- ...\r\n---- Acme/\r\n------ Api/\r\n-------- src/\r\n---------- Acme/\r\n------------ Api/\r\n-------------- Controller/\r\n-------------- ApiServiceProvider.php\r\n------------ filters.php\r\n------------ routes.php\r\n...\r\n```\r\n\r\nContents of the `ApiServiceProvider.php` file\r\n\r\n```php\r\n<?php namespace Acme\\Api;\r\n\r\nuse Illuminate\\Support\\ServiceProvider;\r\n\r\nclass ApiServiceProvider extends ServiceProvider {\r\n\r\n\tprotected $deferred = true;\r\n\r\n\t/**\r\n\t * Bootstrap the application events.\r\n\t *\r\n\t * @return void\r\n\t */\r\n\tpublic function boot()\r\n\t{\r\n\t\t$this->package('acme/api', 'acme-api', $this->getPackagePath());\r\n\r\n\t\t// Load routes definitions and route filters\r\n\t\trequire $this->getPackagePath().'/filters.php';\r\n\t\trequire $this->getPackagePath().'/routes.php';\r\n\t}\r\n\r\n\t/**\r\n\t * Register the service provider.\r\n\t *\r\n\t * @return void\r\n\t */\r\n\tpublic function register()\r\n\t{\r\n\t\t//\r\n\t}\r\n\r\n\t/**\r\n\t * Get the path to the root folder of the package.\r\n\t *\r\n\t * @return string\r\n\t */\r\n\tprotected function getPackagePath()\r\n\t{\r\n\t\treturn realpath(__DIR__.'/../../');\r\n\t}\r\n}\r\n```\r\n\r\nContents of the packages `routes.php` file\r\n\r\n```php\r\n<?php\r\n\r\n$routeGroupAttributes = [\r\n\t'version'\t=> 'v1',\r\n\t'namespace'\t=> 'Acme\\Api\\Controller'\r\n];\r\n\r\nRoute::api($routeGroupAttributes, function () // <-- Here's where the trouble begins, its not defined yet.\r\n{\r\n\t/**\r\n\t * Post route definition(s)\r\n\t */\r\n\r\n\tRoute::resource('post', 'PostApiController');\r\n});\r\n```\r\nHeres my service providers array in the app config file\r\n\r\n```php\r\n$providers = [\r\n    // Laravel's default service providers...\r\n\r\n    'Dingo\\Api\\Provider\\ApiServiceProvider',\r\n    'Dakota\\Api\\ApiServiceProvider',\r\n   \r\n   // My other service providers...\r\n];\r\n```\r\n\r\n**UPDATE**: It works when i move MY packages ApiServiceProvider down the line. So i guess i can live with that. Closing. "}}