Download the PHP package whitecube/laravel-links without Composer
On this page you can find all versions of the php package whitecube/laravel-links. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-links
Links for Laravel
🔗 No more broken internal links!
♻️ Changes made to route structures, model bindings, slugs, etc. are directly transposed to all URLs generated with this package ;
🎯 Display intuitive and exhaustive form fields for links selection ;
💾 Store references to simple or complex URLs where and how you want.
Laravel's routing system is great. With this package, it will become even greater! Using a simple link reference syntax, you'll be able to store and parse URLs on-the-fly and take full advantage of Laravel's routing in rich content such as CMS editors, admin interfaces and other managed configurations.
Building a content page and want to add the possibility to insert links to your application's resources (or even external!) from your admin panel? You basically have two options:
-
Store the full URL as a string and hope it won't change soon:
- Store a short, immutable reference to this URL and let your application resolve its current, working URL at runtime:
You'll get it: the second one is probably the best. However, it can swiftly become quite complex to setup and maintain. That's why we've built a package for it.
Table of contents
- Installation
- Usage
- Registering link resolvers
- Editing & storing link references
- Resolving link URLs
- Using the
Link
instantiation methods - Using the
Links
facade - Using the
Str
facade orstr()
helper - Using Blade directives
- Using model attribute casting
- Using the
- Reporting link resolving issues
Installation
This package will auto-register its service provider.
Usage
First, you'll need to register the application's link resolvers. Link resolvers are objects used to transform immutable link references (such as products.item@216
) into fully qualified URLs. Resolvers can handle any of your application's routes or even complex external URLs. This package ships with a few common resolvers but feel free to create your own!
A good place to start is with a Service Provider. You can use an existing one (why not the application's RouteServiceProvider
?) or create a dedicated Provider (e.g. LinkServiceProvider
). Then, inside the provider's boot
method, provide a resolver definition for each link you'll need to reference:
Of course, your application could have more complex routing configurations that would probably be more difficult to map into link resolvers. This package offers a lot of advanced resolver setup features that could cover your needs, but you can also extend the shipped traits or write your own resolvers.
You can now start resolving them for display.
Registering link resolvers
WIP.
Editing & storing link references
WIP.
Resolving link URLs
As stated above, links can be stored in many ways, depending on your use case. Here are a few common methods that should get you started.
Using the Link
instantiation methods
WIP
Using the Links
facade
WIP
Using the Str
facade or str()
helper
WIP
Using Blade directives
WIP
Using model attribute casting
Beware that model attribute casting can have undesired side-effects on dedicated link editor components since they'll probably rely on the attribute's raw value (meaning "with unresolved link references") to work.
Casting textual content with inline link references (inline tags)
The ResolvedInlineLinkTagsString
cast is useful when a model has attributes containing editorial content with inline link references (also called "inline tags") that all need to be resolved at once.
For instance, a content
attribute containing the following string:
Would be cast into:
Reporting link resolving issues
WIP.
Development Roadmap
Links are at the base of the world wide web. This package aims to "objectify" and take inventory of a project's internal URLs, which opens a lot of possibilites for future features and updates.
- [x] List available link resolvers ;
- [x] Generate URLs from link references/objects ;
- [x] Generate full list of available concrete links for selectors & specialized form UI components ;
- [ ] Replace inline link references with their resolved URL value ;
- [ ] Generate URLs with
@link()
blade directive ; - [ ] Define link resolvers directly on Laravel's routes ;
- [ ] Cast Link objects in models ;
- [ ] Report unresolvable link references ;
- [ ] Generate XML sitemaps based on the links inventory ;
- [ ] Reverse-engineer URLs to detailed Link objects ;
Need some of the unchecked features above? Or want to add items to this list? Open an issue or a PR and we'll take a look at it! But remember, if you want professional support, don't forget to sponsor us! 🤗
🔥 Sponsorships
If you are reliant on this package in your production applications, consider sponsoring us! It is the best way to help us keep doing what we love to do: making great open source software.
Contributing
Feel free to suggest changes, ask for new features or fix bugs yourself. We're sure there are still a lot of improvements that could be made, and we would be very happy to merge useful pull requests. Thanks!
Made with ❤️ for open source
At Whitecube we use a lot of open source software as part of our daily work. So when we have an opportunity to give something back, we're super excited!
We hope you will enjoy this small contribution from us and would love to Twitter for more updates!