
Aloia — A Flat-file CMS for Laravel 9
Aloia CMS is a flat-file content management system for Laravel. You don’t need to rebuild your entire application to offer CMS capabilities, and you can include Aloia in your existing application.
Aloia offers the following content-types out-of-the-box that you can manage as flat files in Markdown or HTML.
- Page
- Article
- ContentBlock
- MetaTag
Let’s take the Article content type as an example and demonstrate how you interact with these flat-file models:
1use AloiaCmsModelsArticle;
2use IlluminateSupportCollection;
3
4// Get a collection of Article[]|Collection
5$articles = Article::all();
6
7// Find an article
8$article = Article::find('this-post-is-amazing');
And a more advanced example of updating an Article, which would then update the flat file in the format chosen:
1use CarbonCarbon;
2
3Article::find('this-post-is-amazing')
4 // md is the default, but you can use html as well.
5 ->setExtension('md')
6 ->setMatter([
7 'description' => 'This post is about beautiful things',
8 'is_published' => true,
9 'is_sechduled' => false,
10 // Either use post_date in setMatter() or setPostDate()
11 'post_date' => date('Y-m-d')
12 ])
13 ->setPostDate(Carbon::now())
14 ->setBody('# This is the content of an article')
15 ->save();
ContentBlock is another interesting content type because it allows you to create partial content blocks and render them in a blade file. For example, given the following content block in Markdown:
1## Title of the content
2
3This is a paragraph
The content block can be edited and later rendered in a Blade file:
1{!! Block::get('test') !!}
Which would render the following output:
1<h2>Title of the content</h2>
2
3<p>This is a paragraph</p>
You can also create [custom content types Creating content types and interact with them like any of the other built-in content types.
Learn More
Check out the Aloia CMS documentation to install this package and learn how to use it. You can learn more about this package, get full installation instructions, and view the source code on GitHub.
Credit: Source link