how to use route to view static apidoc page with laravel
up vote
0
down vote
favorite
I am currently using http://apidocjs.com/ as my laravel apidoc because I am just used to it before.
to view the apidoc, each time I have to drag the index.html
into the browser which is quite annoying.
Is it possible to make it into a static page so people I am sharing the apidoc with can just generate the doc then go to the route.
I tried something like...putting my apidoc
folder under public
folder of the application and also tried adding a route such as
Route::get('/apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Both of them didn't work the index.html
cannot load the css
and js
because in index.html
the source url is something like vendor/polyfill.js
which then tried to go localhost:8000/vendor/polyfill.js
but actually the url should be something like localhost:8000/apidoc/vendor/polyfill.js
Does anyone know how to easily fix this?
Thanks in advance for any help
php laravel routes api-doc static-pages
add a comment |
up vote
0
down vote
favorite
I am currently using http://apidocjs.com/ as my laravel apidoc because I am just used to it before.
to view the apidoc, each time I have to drag the index.html
into the browser which is quite annoying.
Is it possible to make it into a static page so people I am sharing the apidoc with can just generate the doc then go to the route.
I tried something like...putting my apidoc
folder under public
folder of the application and also tried adding a route such as
Route::get('/apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Both of them didn't work the index.html
cannot load the css
and js
because in index.html
the source url is something like vendor/polyfill.js
which then tried to go localhost:8000/vendor/polyfill.js
but actually the url should be something like localhost:8000/apidoc/vendor/polyfill.js
Does anyone know how to easily fix this?
Thanks in advance for any help
php laravel routes api-doc static-pages
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am currently using http://apidocjs.com/ as my laravel apidoc because I am just used to it before.
to view the apidoc, each time I have to drag the index.html
into the browser which is quite annoying.
Is it possible to make it into a static page so people I am sharing the apidoc with can just generate the doc then go to the route.
I tried something like...putting my apidoc
folder under public
folder of the application and also tried adding a route such as
Route::get('/apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Both of them didn't work the index.html
cannot load the css
and js
because in index.html
the source url is something like vendor/polyfill.js
which then tried to go localhost:8000/vendor/polyfill.js
but actually the url should be something like localhost:8000/apidoc/vendor/polyfill.js
Does anyone know how to easily fix this?
Thanks in advance for any help
php laravel routes api-doc static-pages
I am currently using http://apidocjs.com/ as my laravel apidoc because I am just used to it before.
to view the apidoc, each time I have to drag the index.html
into the browser which is quite annoying.
Is it possible to make it into a static page so people I am sharing the apidoc with can just generate the doc then go to the route.
I tried something like...putting my apidoc
folder under public
folder of the application and also tried adding a route such as
Route::get('/apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Both of them didn't work the index.html
cannot load the css
and js
because in index.html
the source url is something like vendor/polyfill.js
which then tried to go localhost:8000/vendor/polyfill.js
but actually the url should be something like localhost:8000/apidoc/vendor/polyfill.js
Does anyone know how to easily fix this?
Thanks in advance for any help
php laravel routes api-doc static-pages
php laravel routes api-doc static-pages
asked Nov 12 at 6:46
Tsuna
5971720
5971720
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You can "cheat" a little bit by registering the vendor routes as well:
Route::get('vendor/{any}', function ($any) {
abort_unless(is_readable(public_path("apidoc/vendor/$any")), 404);
return File::get(public_path("apidoc/vendor/$any"));
})->where('any', ".*");
Route::get('apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Of course the ideal solution is if you actually manage to change the template you use for index.html to use relative and not absolute paths (i.e. change all <link href='/vendor...'>
to <link href='vendor...'>
so the file can automatically request the correct resource.
I get what you meant, but somehow still getting errors for getting files :(
– Tsuna
Nov 15 at 1:27
it's a good trick, I will try figuring out the rest of 404 errors. Thanks thanks a lot ^_^, the thing is theindex.html
template is generated by other services
– Tsuna
Nov 15 at 1:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257098%2fhow-to-use-route-to-view-static-apidoc-page-with-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can "cheat" a little bit by registering the vendor routes as well:
Route::get('vendor/{any}', function ($any) {
abort_unless(is_readable(public_path("apidoc/vendor/$any")), 404);
return File::get(public_path("apidoc/vendor/$any"));
})->where('any', ".*");
Route::get('apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Of course the ideal solution is if you actually manage to change the template you use for index.html to use relative and not absolute paths (i.e. change all <link href='/vendor...'>
to <link href='vendor...'>
so the file can automatically request the correct resource.
I get what you meant, but somehow still getting errors for getting files :(
– Tsuna
Nov 15 at 1:27
it's a good trick, I will try figuring out the rest of 404 errors. Thanks thanks a lot ^_^, the thing is theindex.html
template is generated by other services
– Tsuna
Nov 15 at 1:51
add a comment |
up vote
2
down vote
accepted
You can "cheat" a little bit by registering the vendor routes as well:
Route::get('vendor/{any}', function ($any) {
abort_unless(is_readable(public_path("apidoc/vendor/$any")), 404);
return File::get(public_path("apidoc/vendor/$any"));
})->where('any', ".*");
Route::get('apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Of course the ideal solution is if you actually manage to change the template you use for index.html to use relative and not absolute paths (i.e. change all <link href='/vendor...'>
to <link href='vendor...'>
so the file can automatically request the correct resource.
I get what you meant, but somehow still getting errors for getting files :(
– Tsuna
Nov 15 at 1:27
it's a good trick, I will try figuring out the rest of 404 errors. Thanks thanks a lot ^_^, the thing is theindex.html
template is generated by other services
– Tsuna
Nov 15 at 1:51
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can "cheat" a little bit by registering the vendor routes as well:
Route::get('vendor/{any}', function ($any) {
abort_unless(is_readable(public_path("apidoc/vendor/$any")), 404);
return File::get(public_path("apidoc/vendor/$any"));
})->where('any', ".*");
Route::get('apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Of course the ideal solution is if you actually manage to change the template you use for index.html to use relative and not absolute paths (i.e. change all <link href='/vendor...'>
to <link href='vendor...'>
so the file can automatically request the correct resource.
You can "cheat" a little bit by registering the vendor routes as well:
Route::get('vendor/{any}', function ($any) {
abort_unless(is_readable(public_path("apidoc/vendor/$any")), 404);
return File::get(public_path("apidoc/vendor/$any"));
})->where('any', ".*");
Route::get('apidoc', function(){
return File::get(public_path() . '/apidoc/index.html');
});
Of course the ideal solution is if you actually manage to change the template you use for index.html to use relative and not absolute paths (i.e. change all <link href='/vendor...'>
to <link href='vendor...'>
so the file can automatically request the correct resource.
answered Nov 12 at 6:57
apokryfos
18k42955
18k42955
I get what you meant, but somehow still getting errors for getting files :(
– Tsuna
Nov 15 at 1:27
it's a good trick, I will try figuring out the rest of 404 errors. Thanks thanks a lot ^_^, the thing is theindex.html
template is generated by other services
– Tsuna
Nov 15 at 1:51
add a comment |
I get what you meant, but somehow still getting errors for getting files :(
– Tsuna
Nov 15 at 1:27
it's a good trick, I will try figuring out the rest of 404 errors. Thanks thanks a lot ^_^, the thing is theindex.html
template is generated by other services
– Tsuna
Nov 15 at 1:51
I get what you meant, but somehow still getting errors for getting files :(
– Tsuna
Nov 15 at 1:27
I get what you meant, but somehow still getting errors for getting files :(
– Tsuna
Nov 15 at 1:27
it's a good trick, I will try figuring out the rest of 404 errors. Thanks thanks a lot ^_^, the thing is the
index.html
template is generated by other services– Tsuna
Nov 15 at 1:51
it's a good trick, I will try figuring out the rest of 404 errors. Thanks thanks a lot ^_^, the thing is the
index.html
template is generated by other services– Tsuna
Nov 15 at 1:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257098%2fhow-to-use-route-to-view-static-apidoc-page-with-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown