laravel / folio Goto Github PK
View Code? Open in Web Editor NEWPage based routing for Laravel.
License: MIT License
Page based routing for Laravel.
License: MIT License
v1.0.0-beta.1
10.16.0
8.2.8
❯ laravel (production) ✘ php artisan folio:make user/profile
ERROR Command "folio:make" is not defined. Did you mean one of these?
⇂ folio:install
⇂ folio:list
I followed the steps in the README
composer require laravel/folio:^1.0@beta
php artisan folio:install
I'm trying to localize my app with Folio without creating duplicated lang directories inside /pages
So far I came up with this, but the problem is that localized Folio routes are being overwritten by each others and using the route()
helper leads to the same url. Is there a way to suffix route names with dynamic value, in my case would be the current locale?
Folio::path(resource_path('views/pages'))
->uri('en')
->middleware([
'*' => ['lang:en'],
]);
Folio::path(resource_path('views/pages'))
->uri('fr')
->middleware([
'*' => ['lang:fr'],
]);
lang middleware
public function handle(Request $request, Closure $next, string $lang): Response
{
// Set application locale
app()->setLocale($lang);
// Remember the last known locale for automatic redirects
if ($request->cookie('last_known_locale', null) !== $lang) {
cookie()->queue('last_known_locale', $lang, 60 * 24 * 365);
}
return $next($request);
}
routes/web.php
Route::get('{path}', function (Request $request) {
$lang = $request->cookie('last_known_locale', null);
$lang ??= config('app.fallback_locale');
return redirect()->to($lang.'/'.$request->path());
})
->where('path', '^(?!(en|fr)).*');
index.blade.php
<?php
use function Laravel\Folio\name;
name('home');
?>
php artisan folio:list
GET /en ....... home › resources/views/pages/index.blade.php
GET /fr ....... home › resources/views/pages/index.blade.php
There appears to be an API exposed for using Folio with a custom response Folio::renderUsing
. However, if I do something like the following to render components with Inertia, it only works when I have the same directory structure in the default views/pages
folder.
Folio::renderUsing(function (Request $request, MatchedView $matchedView) {
$path = Str::between($matchedView->relativePath(), '/', '.blade.php');
return Inertia::render($path, $matchedView->data);
});
Folio::route(resource_path('views/pages'), middleware: [
'*' => [
//
],
]);
example directory structure that successfully renders svelte components using Inertia:
/
└── resources
├── views
│ └── index.blade.php
│ └── users
│ ├── [User].blade.php
│ └── index.blade.php
└── js
└── Pages
└── index.svelte
└── users
├── [User].svelte
└── index.svelte
ideally we could modify the resource path and add a value in a config file or in the service provider to tell Folio to search for svelte files instead of blade files so we could have the following directory structure instead:
/
└── resources
└── js
└── Pages
└── index.svelte
└── users
├── [User].svelte
└── index.svelte
The setup could look something like this:
Folio::extension('svelte');
Folio::renderUsing(function (Request $request, MatchedView $matchedView) {
return Inertia::render($matchedView->relativePath(), $matchedView->data);
});
Folio::route(resource_path('js/Pages'), middleware: [
'*' => [
//
],
]);
Perhaps this is not the purpose of Folio and therefore this ticket can be closed, but considering that we have different types of HTTP methods, it would be extremely useful if Folio supported this following the following pattern:
contact.blade.php // GET ...
create.post.blade.php
destroy.delete.blade.php
update.put.blade.php
I could suggest that this feature is possible via the FolioServiceProvider
, but if Folio intends to support routes via files, IMO the best place would be the prefix shown above.
If I'm totally wrong and the Folio will never support other HTTP methods instead of GET
, then shouldn't this at least be documented?
1.0.0
10.20.0
8.2.4
Folio returns a 404 when using a session within a Global Scope in an Eloquent model.
session('test')
returns null
; in plain Laravel it returns the actual session data.
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Database\Eloquent\Builder;
class Test extends Model
{
protected static function boot()
{
parent::boot();
static::addGlobalScope('test', fn (Builder $builder) => $builder->where('test', session('test')));
}
}
// folio/[Test]/edit.blade.php
{{ $test->id }}
This is a placeholder for a PR that allows me (or end users) to solve this issue without Laravel maintaining anything.
Original tweet: https://twitter.com/snellingio/status/1688643282408964097
Pitch I made in the internals discord:
It would be cool to add a method to compile an anonymous class or function to handle post requests.
Currently: Laravel Volt allows us to very easily hook up forms with Folio page routing.
Imagine a contact-us form.
pages
└── contact-us.blade.php
The Volt component would look something like:
<?php
use function Livewire\Volt\{rules, state};
state(['issue_type' => '', 'message' => '', 'email' => '',);
rules([ 'issue_type' => ['bail', 'required'], 'message' => ['required'], 'email' => [ 'required', 'email', ],]);
$save = function () {
// do the work
};
?>
…
<form wire:submit="save">
This is amazing. However, there are a lot of times / projects that I’m not using Livewire.
I’d love if we had some sort of post or store helper inside folio directly.
<?php
use function Laravel\Folio\{post};
post(function(Request $request) {
// do the work
});
?>
…
<form action="/contact-us" method="POST">
I think it would work the exact same, it just compiles to an anon function. The actual route would stay the same, and we could route based on the request type.
1.1.4
10.32.1
8.2.4
When I run php artisan folio:list
, the returned path is missing the URI-prefix when specified.
I get this:
GET /test ......
I expect the result to be this:
GET /foo/test ......
Put this method in your FolioServiceProvider
:
/**
* Bootstrap services.
*/
public function boot(): void
{
Folio::path(resource_path('foobar'))->middleware([
'*' => [
//
],
])->uri('foo/');
}
run php artisan folio:list
1.1.5
10.37.3
8.1.4
Folio::path(resource_path("views/pages/"));
Folio::domain('domain-one.test')->path(resource_path("views/pages/tenants/one"));
Folio::domain('domain-two.test')->path(resource_path("views/pages/tenants/two"));
First and 2nd line is working. but 2nd or any next domain is not working.
foreach($domains as $domain)
{
Folio::domain($domain->domain)->path(resource_path("views/pages/tenants/$domain->slug"));
}
in above code only first domain is working. any next domains are not working
in FolioServiceProvider
public function boot(): void
{
Folio::path(resource_path("views/pages/"));
Folio::domain('domain-one.test')->path(resource_path("views/pages/tenants/one"));
Folio::domain('domain-two.test')->path(resource_path("views/pages/tenants/two"));
}
v1.0.0-beta.1
v10.16.1
8.1.10
I'm using Laravel with Laragon on Windows, every time I try to load some blade file in the default Folio folder ('/view/pages') Laravel throws a PossibleDirectoryTraversal Exception.
Looking in the sources of the package, the problem seems located in vendor/laravel/folio/src/Pipeline/EnsureNoDirectoryTraversal.php at row 22:
if (! Str::of(realpath($view->path))->startsWith($state->mountPath.'/')) { throw new PossibleDirectoryTraversal; }
Using dd() the result of realpath($view->path) has a different ending char than $state->mountPath.'/'
realpath($view->path) => C:\laragon\www\filamentv3\resources\views\pages\index.blade.php"
$state->mountPath.'/' => "C:\laragon\www\filamentv3\resources\views\pages/"
php artisan make:folio index
Is it possible to add support for query string?
I read the current docs on GitHub and it is nice to have segment, multiple segment, route model binding, and customizing the model key. I might have miss it but I can't find how to use query string on Laravel Folio. Somehow I need it on most of my project and I fall in love with this Laravel Folio.
1.0.0-beta.4
10.18.0
8.1
When I use folio with route model binding for a model named Event, it thows this error:
Folio route attempting to bind to class [Event], but it does not implement the UrlRoutable interface.
This doesn't happen for my other models. And it doesn't happen when I specifically tells it where the model is using [.App.Models.Event].blade.php as the filename.
I'm wondering whether it's picking up another Event class from somewhere else?
Create a model called Event.
Create the folio page: php artisan make:folio "events/[Event]"
Access the page with /events/[event-id]
Error is thrown.
1.0.0-beta.3
v10.17.1
8.2.8
On a fresh laravel application with folio installed, it is no longer possible to cache the routes.
The following error occurs.
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 606208 bytes) in vendor/laravel/framework/src/Illuminate/Routing/Route.php on line 1343
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php on line 480
laravel new folio-test
cd folio-test
composer require laravel/folio:^1.0@beta
php artisan folio:install
php artisan route:cache
So from a brand new installation of Laravel I just added folio and vapor-core and had a site up in "no time".
That got me wondering - if I had a simple content site - like documentation of a product say, could all the "other stuff" like models, controllers be removed from the base framework? Does this impact the size of the lambda function?
I see there is scope for models so this is only for the simple site use case.
1.1.3
10.22.0
8.2.3
Hello team,
Thanks for the great job. Laravel Folio is really amazing.
Thus, I don't know if I should create a new issue for it has almost the same topic.
I still have some routes (files) that are not accessible due to collision with another wildcard route.
The route /create
is not reachable. When trying to access it, Folio keeps using /{id}
and just passes the term create
as $id
.
Create a new Laravel project using Folio and the following tree structure (without implicit model binding).
I think it would be great if we could add metadata to a folio page. I am thinking of how it works in Nuxt with Nuxt Content if your familiar (https://content.nuxtjs.org/guide/writing/markdown).
In Nuxt your content
directory (similar concept to the resources/views/pages/*
) which may look like
---
type: 'blog'
title: 'Title of the page'
description: 'meta description of the page'
---
<!-- Content of the page -->
A purpose for these front-matter metadata is to be able to query the pages and display them in a list. For example, if you have a blog you may want to display a list of all the blog posts that based on some criteria.
an implementation of this could be something like
collect(Folio::pages())->where('type', 'blog')->sortBy('createdAt')->take(5);
More on the metadata part...idk exactly how it would work best, maybe something like:
<?php
use function Laravel\Folio\{metadata};
metadata([
'type' => 'blog',
'title' => 'Dashboard',
'description' => 'meta description of the page',
]);
?>
<div>
Blogs
</div>
1.0.0
Latest
8.1.21
I don't know if an update to README.md
(docs) is enough or if the Laravel team wants to do something about it, but the multi-parameter route system eliminates Route Model Bidding:
Something like this:
When accessing profiles/1
in the browser, [...ids].blade.php
have priority over [User].blade.php
, even [User].blade.php
was created after. Perhaps the Laravel team knows about this and is aware, but here's my suggestion 👇
make:folio
:The make:folio
command can intercept this situation and give a visual feedback to the dev.
The access of a route that contains a trying to use Route Model Bidding together of Route Multi-Segments can simple try and exception providing a feedback to the dev.
Hope this help,
Thanks.
make:folio "profiles/[...ids]"
make:folio "profiles/[User]"
profiles/1
and check that [...ids]
will works instead of [User]
1.1.3
10.4.1
8.2.11
Consider the following view: resources/views/pages/users/[...ids].blade.php
<ul>
@forelse(\App\Models\User::whereIn('id', $ids)->get() as $user)
<li>{{ $user->email }}</li>
@empty
<li>No users available</li>
@endforelse
</ul>
When you browse to /users
you might expect to see 'No users available', however instead you will get 404
.
Install folio and paste the above contents into resources/views/pages/users/[...ids].blade.php
, then browse to '/users' in your application
The three main struggles with folio (and volt) are intellisense, static analysis and error reporting.
The first two depend on your dev environment, and ide
's and lsp
's are continuing to evolve to help with that.
Error reporting is still a problem though. Errors often aren't caught before the blade view is compiled, and errors aren't caught at "compile time" (I'm referring to the blade compiler here).
If the error occurs in the template, we often have no idea where in the template it occurred. I find myself struggling to get good reporting and spending a lot of time in tools like spatie/ray
or just ddd()
ing all the time to figure things out.
It's nice to have a quick feedback loop, but how can we improve the quality of the feedback? Are there some best practices that might be useful to have in the docs? Can we pass some kind of debug flags to the blade compiler from folio views, maybe send line numbers through for the @php
code blocks?
PS:
I know that a fair answer to this is: "If you want better stack trace and language support use a psr-4 controller instead of folio, and do exhaustive error checking before returning your view". I'm just shaking the tree here to see if anything good or helpful falls out.
kindly use a Service class in Config which will return a string value from .env file for getting default path which is "views/pages".
so from .env file a developer can change default directory. and that class can be replaced by new call in case of complex directory structure like modules, multitenancy, etc.
Hello,
I couldn't find a way to implement named routes in Folio.
That would be a pretty important feature to me, since I can't generate links to Folio pages via the route() helper.
I checked the output of "artisan route:list" and it doesn't seem like it is registering routes at all?
Edit: Ah ok, all under one route, I see.
Thanks!
The view()
helper can also be used to reach for plain vanilla (non-blade) .php
files. Is there a way to do this with folio as well?
In the case where there may be any reason you want to preserve paths and/or don't need the extra compile step in some views.
EDIT:
I see where '.blade.php' is hard coded in the Match
pipeline. Any plans to allow customizing or extending the pipeline, or any interest in a PR to that effect? In fact if the Pipeline and renderer could be extended, I can foresee a wide variety of use cases for other file types as well, including markdown and html.
1.0.0-beta.1
10.16.1
8.1.10
When trying on a Windows system, I found a problem with verifying that the blade file exists at Laravel\Folio\Pipeline\EnsureNoDirectoryTraversal
class.
if (! Str::of(realpath($view->path))->startsWith($state->mountPath.'/')) {
throw new PossibleDirectoryTraversal;
}
And I solved the problem through the use DIRECTORY_SEPARATOR
to be
if (! Str::of(realpath($view->path))->startsWith($state->mountPath . DIRECTORY_SEPARATOR)) {
throw new PossibleDirectoryTraversal;
}
Thanks,
php artisan folio:install
.pages/schedule.blade.php
fileIf we have such dir structure:
/pages
about.blade.php
/[Post-slug]
index.blade.php
navigating to /about
should - in my opinion - load about.blade.php
instead of looking for a Post with slug = 'about'
.
It works correctly if we make /about
dir and put index.blade.php
inside but wouldn't the above solution be more convenient?
v1.0.0-beta.2
v10.17.1
8.2.8
When registering terminable middleware in the FolioServiceProvider
, the terminate()
function of the middleware isn't executed.
terminate()
method: info('terminating')
FolioServiceProvider
:
Folio::route(resource_path('views/pages'), middleware: [
'*' => [
TheTerminableMiddleware::class,
],
]);
terminating
log entry1.0.0-beta.1
10.16.1
8.1
Not sure if this is a bug or not, but if a view component is used inside a Folio page as the 'top level' component, e.g. as a layout component, parameters do not get passed to the component. But it does get passed through once it's nested inside another div.
E.g. this doesn't pass the title
parameter:
<x-app-layout title="Videos">
...
</x-app-layout>
But this does:
<div>
<x-app-layout title="Videos">
...
</x-app-layout>
</div>
1.0.0
10.4.1
8.1.4
You may want to reach out to this developer:
https://github.com/nonoesp/laravel-folio
N/A
Coming from ded968e#commitcomment-123084859:
10 hexadecimal characters have an entropy of 40 bits. That is very low (for perspective, only barely above CRC32, which is very prone to collision).
I would suggest to slightly raise the number of characters.(see the 2nd table at https://en.wikipedia.org/wiki/Password_strength#Random_passwords)
Excerpt from the mentioned table:
Entropy | Hexadecimal chars |
---|---|
8 bits | 2 |
32 bits | 8 |
40 bits | 10 |
64 bits | 16 |
80 bits | 20 |
96 bits | 24 |
128 bits | 32 |
160 bits | 40 |
192 bits | 48 |
224 bits | 56 |
256 bits | 64 |
As you can see at the bottom of this article, 32-bit is insanely low:
Therefore, I would recommend no less than 16 characters (entropy of 64 bits).
Firstly - I think this is brilliant for super simple sites that don't need too much complexity on the routing front.
As I said in the title - could other file types work?
That would be awesome.
Priority: NTH (Nice to have)
I'd just finish installation of the Folio package to try it out on an existing project. After do some configurations I get this error:
My suggestion is to create the path instead of throws an error
public function registerRoute(string $path, string $uri, array $middleware, ?string $domain): void
{
$absolutePath = $path;
$path = realpath($absolutePath);
$uri = '/'.ltrim($uri, '/');
if (! is_dir($path)) {
mkdir($absolutePath, 0777, true);
}
$this->mountPaths[] = $mountPath = new MountPath(
$path,
$uri,
$middleware,
$domain,
);
Route::fallback($this->handler())->name('laravel-folio');
}
It would be really nice to have fragments.
Something like:
<?php
use function Laravel\Folio\{fragmentIf};
fragmentIf(request()->hasHeader('HX-Request'), 'user-list');
?>
@fragment('user-list')
<ul>
@foreach ($users as $user)
<li>{{ $user->name }}</li>
@endforeach
</ul>
@endfragment
https://laravel.com/docs/10.x/blade#rendering-blade-fragments
Thoughts?
1.1.0
^10.10
^8.1
I can not access the shared variable inside the new render
function between @php
and @endphp
directives. Let me demonstrate with the next two examples of code
// The code example that @nunomaduro uses
<?php
use function \Laravel\Folio\render;
render( function($view) {
$post = ['title' => 'Welcome Render Method!'];
return $view->with('post', $post);
});
?>
// The value of `title` is printed out successfully
<?php echo $post['title']; ?>
But when I use the previous code between @php
and @endphp
directives the Undefined variable $post error is triggered
@php
use function \Laravel\Folio\renderWhen;
renderWhen(true, function($view) {
$post = ['title' => 'Welcome Render Method!'];
return $view->with('post', $post);
});
@endphp
@dd($post);
NULL
Originally from a tweet: https://twitter.com/snellingio/status/1688646569157939201?s=20
Followed up with a pitch inside the internals
discord.
Putting this here as a placeholder for a PR.
Currently: To render a markdown file, you need to wrap in a .blade.php
. So, to render something like a post, or a terms of service, etc, you end up needing a blade file.
pages
└── terms-of-service.blade.php
And the content would look something like
<x-layouts.app title="Terms of Service">
<x-markdown>
# Terms of Service
[...]
</x-markdown>
</x-layouts.app>
What I really want to do is just have a markdown file.
pages
└── terms-of-service.md
And the content could use YAML front matter (as is the standard in other page / routing frameworks) to pass in blade options. The actual content would go into the $slot variable as one would expect.
---
component: x-layouts.app
title: Terms of Service
---
# Terms of Service
[...]
Unsure if it would be best named as component or layout but that's all I would really need to wrap it all up.
This has a lot of benefits, from cross-platform drag and drop, to editor preview rendering!
1
10
8
Route::has
doesn't seem to pick up folio pages.
Example, in my navbar:
@if(Route::has('login'))
<a href="{{ route('login') }}">
{{ __('Login') }}
</a>
@endif
In my login.blade.php
page:
use function Laravel\Folio\name;
name('login');
My link for the login page doesn't show up in the navbar.
Create a view that uses Route::has
to check if a named folio page exists. Seems to always be false.
1.1.0
10.10
8.2.8
index
blade file, with deeply nested routes with model binding not working as expectedWhen trying to use route binding using multiple nested folders:
user/[.App.Models.User]/posts/[.App.Models.Post]/index.blade.php
Works as expected when using:
user/[User]/posts/[Post].blade.php
user/[.App.Models.User]/posts/[.App.Models.Post].blade.php
Create a simple structure as:
Hi,
Is there way to configure folio for different subdomain grouping like normal route ?
->domain()
1.1.2
10.26.2
8.2.3
This issue is, I think, related to the issue #105 and was introduced in version 1.1.1
When using Folio I'm unable to display a create page when a subfolder [Model] exists.
The index page is however correctly displayed.
Here's what my pages folder look like:
And here's what php artisan folio:list
shows:
movies/index.blade.php
correctly displays all of my moviesmovies/[Movie].blade.php
correctly displays the details of a single movie (if i change it to movies/[Movie]/index.blade.php
it also works)movies/[Movie]/characters.blade.php
correctly displays all characters in a moviemovies/create.blade.php
doesn't work and returns a 404 errorIf I remove the [Movie] folder the create page is displayed.
If I force composer to use v1.1.0 everything works as intended.
I think it would be nice to use Folio base routing and the controller based routing for the same parent route.
Example
The url /products
is created using Laravel Folio and the route /products/{id}
being used with a controller in the web.php
file.
Hey,
we set up our first folio project und we prefer using twig (via twigbridge) over blade templates.
Folio don't finds templates with .twig extension. After digging the code a little, i found many hardcoded ".blade.php" refreences.
Wouldn't it be nice if the template extension is configurable via config?
Thanks in advance!
right now when we use folio with volt we must add @volt
directive and <x-layouts.app>
tag to our full page components, e.g.:
<x-layouts.app>
@volt
<h1>hello world</h1>
<button wire:click="incrementCount">increment count</button>
@endvolt
</x-layouts.app>
when registering full page components directly with volt, we use the Volt::route
method:
Vote::route('/', 'index');
when we do it this way, we do not need to use the @volt
directive or the layout tag in our view:
<div>
<h1>hello world</h1>
<button wire:click="incrementCount">increment count</button>
</div>
what if we could simply specify this class & method via the Folio
registrar?:
Folio::path(resource_path('views/pages'))
->action([Volt::class, 'route'])
->middleware([
'*' => [
//
],
]);
or even add a new method to Folio
that uses an abstraction for volt:
Folio::path(resource_path('views/pages'))
->volt()
->middleware([
'*' => [
//
],
]);
this way all our folio pages will be interactive without requiring additional directive, and would also use the default livewire layouts.app
component.
i can submit PR if you're interested
thoughts?
1.1.5
10.43
8.2
Hello,
Thanks for the great job. Laravel Folio is really cool thing.
I have some categories and pages on my website, which have url path like:
domain.com/carrier/indexed/safe-return OR domain.com/carrier/fixed/index-protector-7
So the problem is that Folio is replacing all "/index" and "/index/" strings in the whole url if route() function was used to generate url. And result will be:
domain.com/carrier/ed/safe-return OR domain.com/carrier/fixed-protector-7
As you may understand, all "/index" were removed from URL, so I can't generate url correctly using route() function. If copy/paste full url to browser or generate it in another way, it works.
I found it's happening in FolioRoutes.php class.
Any chance it can be fixed somehow? Got a lot of pages with a slugs like "some-page/index-some-name".
Create strtucture like:
Try to generate url using route() function.
Url for /indexed/ folder will not be generated correctly.
Second problem, create any model and give slug like "index-protector-7" and try to make a url like domain.com/index-protector-7 using route() function. Part "/index" will be removed from url.
1
10
8
what is the recommended way of declaring package routes to be handled by folio?
is it like this?:
public function boot(): void
{
Folio::path(base_path('vendor/myname/mypackage/resources/views/pages'))->middleware([
'*' => [
//
],
]);
}
see description
1.1.3
10.28.0
8.2.10
When using Folio I'm unable to display a create page when a subfolder [id] exists.
The index page is however correctly displayed.
Here's what my pages folder look like:
And here's what php artisan folio:list shows:
The admin/properties/index.blade.php works perfectly
The admin/properties/[id]/index.blade.php works perfectly
The admin/properties/[id]/edit.blade.php works perfectly
The admin/properties/create.blade.php ERROR, it is working as admin/properties/[id]/index.blade.php, as I show below:
If I remove the "admin/properties/[id]" folder the create page is displayed.
1.0.0
10.20
8.2
I'm having this problem when trying to use subdomain following the documentation. Could it be a bug? that is not injecting the subdomain into the blade?
app/Providers/FolioServiceProvider.php
class FolioServiceProvider extends ServiceProvider
{
...
public function boot(): void
{
Folio::path(resource_path('views/pages'))->middleware([
'*' => [
//
],
]);
Folio::domain('{account}.laravel.docker')
->path(resource_path('views/pages/painel'));
}
...
}
resources/views/pages/painel/index.blade.php
<div class="row">
<div class="col-md-12">
<h1 class="page-header">Hello {{$account}} </h1>
</div>
</div>
Error:
Undefined variable $account
Currently, named routes don't support passing in query parameters to route
, which doesn't provide 100% feature parity with native named routes. I noticed this while updating my test app tangerine to support named routes.
I also confirmed this by updating the feature parity test and appending a query parameter.
test('feature parity', function () {
Route::get('/posts/{lowerCase}/{UpperCase}/{podcast}/{user:email}/show', function (
string $id,
string $upperCase,
Podcast $podcast,
User $user) {
//
})->name('users.regular');
$parameters = [
'lowerCase' => 'lowerCaseValue',
'upperCase' => 'UpperCaseValue',
'podcast' => Podcast::first(),
'user' => User::first(),
'query' => 'string',
];
$expectedRoute = '/posts/lowerCaseValue/UpperCaseValue/1/[email protected]/show?query=string';
$route = route('users.regular', [
'lowerCase' => 'lowerCaseValue',
'UpperCase' => 'UpperCaseValue',
'podcast' => Podcast::first(),
'user' => User::first(),
'query' => 'string',
], false);
expect($route)->toBe($expectedRoute);
$route = route('posts.show', $parameters, false);
expect($route)->toBe($expectedRoute);
});
This fails the expectation for Folio's named routes, but not for the native named routes:
FAILED Tests\Feature\NameTest > feature parity
Failed asserting that two strings are identical.
-'/posts/lowerCaseValue/UpperCaseValue/1/[email protected]/show?query=string'
+'/posts/lowerCaseValue/UpperCaseValue/1/[email protected]/show'
at tests/Feature/NameTest.php:103
99▕ expect($route)->toBe($expectedRoute);
100▕
101▕ $route = route('posts.show', $parameters, false);
102▕
➜ 103▕ expect($route)->toBe($expectedRoute);
104▕ });
105▕
106▕ test('model route binding wrong column', function () {
107▕ $parameters = [
1 tests/Feature/NameTest.php:103
Tests: 1 failed (2 assertions)
Duration: 0.08s
This is used internally by Laravel, say password reset when generating the URL for the notification, which adds the users' email as a query parameter. Using a regular named route adds the query parameter, while Folio doesn't.
Would be great if Folio also supported adding query parameters when generating a URL with route
.
Instead of manually go to each view and set the route name Laravel\Folio\name('website.register')
, wouldn't be nice to set default route name for each view/page dynamically?
For example pages/login.blade.php => route('login')
and pages/users/profile => route('users.profile')
Aaand to be greedy would add As()
option to the Folio::path(..)->as('website.')
, so all routes now inside this path would have its route name as route('website.login')
and ('website.users.profile')
This is just a feature idea I thought about the other day, Thanks 💌
1.1.3
10.22.0
8.2.3
It seems like the Folio route model binding resolution happens before middlewares are applied 🤔. Thus, in my case, I had a middleware in charge of changing the current database connection dynamically.
I tried using the default routing system in the same project and things started working as expected. Back to Folio, it's no longer working (resolving the suitable database connection).
Using Folio, create a middleware that sets the default database connection. Route model binding will still use the default.
1.0.0-beta.4
10.18.0
8.2.8
When trying to create a page named [Model:key].blade.php
for model binding, Windows won't allow ":" in file names.
I don't know if we could use an alternate character on Windows, or if we could just add another character with the same effect but that would be valid on Windows (so Linux users would have 2 ways of writing it).
On Windows, these are illegal characters in filenames: \ / : * ? " < > |
So I guess we could use characters that are illegal in PHP classes and function names such as: ! @ # $ % & ; , . ~
I'm sorry because I love the ":" separator, it's very clear and nice. Just unusable on Windows.
On Windows
$ php artisan make:folio things/[Thing:number]
INFO Page [C:\laragon\www\application\resources\views\pages/things/[Thing:number].blade.php] created successfully.
Creates an empty folder named "thing" instead.
I'm building an app that will use Folio and Volt. Because this app does not have an API, I removed the RouteServiceProvider
as I think this is unnecessary for this app. By removing the RouteServiceProvider
, I lost the ability to create a fallback
router, and that caused me to open this feature request.
As Folio's proposal is to offer routes based on files, there are scenarios like this one where we are creating a simple website that doesn't require routes to be created via routes/web.php
- also because it loses the sense of using Folio, I believe that it is extremely necessary to create a way to define a fallback - a Folio file that, when it exists, receives all requests that don't match any other Folio route. When the file does not exist, we can then allow a 404 status.
The fallback route can match: [].blade.php
An ErrorException
is thrown when there is a file like pages/[].blade.php
at the root of the project. Perhaps the Folio is one step closer to allowing fallback? 🤔
"Why not only restore RouteServiceProvider to create a route by routes/web.php?"
RouteServiceProvider
and default routes for that.v1.0.0-beta.6
10.19.0
8.2.3
When using a named route in Laravel Folio the Route::currentRouteName()
function returns "laravel-folio" instead of the route name defined in the name
function. I'm not sure if this is required for Folio's magic or just unintended.
name('about')
Route::currentRouteName()
equals "laravel-folio" instead of "about"A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.