-
Docs
Backend
-
Behaviors
-
Classes
-
Controllers
-
Database
-
Seeds
-
-
Facades
-
FormWidgets
-
Helpers
-
Exception
- Backend
-
-
Models
-
ReportWidgets
-
Skins
-
Traits
-
Widgets
- ServiceProvider
-
-
Cms
-
Classes
- Asset
- AutoDatasource
- CmsCompoundObject
- CmsController
- CmsException
- CmsObject
- CmsObjectCollection
- CodeBase
- CodeParser
- ComponentBase
- ComponentHelpers
- ComponentManager
- ComponentPartial
- Content
- Controller
- Layout
- LayoutCode
- MediaLibrary
- MediaLibraryItem
- MediaViewHelper
- Meta
- ObjectMemoryCache
- Page
- PageCode
- Partial
- PartialCode
- PartialStack
- Router
- Theme
- ThemeManager
-
Components
-
Contracts
-
Controllers
-
Facades
-
FormWidgets
-
Helpers
-
Models
-
ReportWidgets
-
Traits
-
Twig
- ComponentNode
- ComponentTokenParser
- ContentNode
- ContentTokenParser
- DebugExtension
- DefaultNode
- DefaultTokenParser
- Extension
- FlashNode
- FlashTokenParser
- FrameworkNode
- FrameworkTokenParser
- Loader
- PageNode
- PageTokenParser
- PartialNode
- PartialTokenParser
- PlaceholderNode
- PlaceholderTokenParser
- PutNode
- PutTokenParser
- ScriptsNode
- ScriptsTokenParser
- StylesNode
- StylesTokenParser
-
Widgets
- ServiceProvider
-
-
System
-
Behaviors
-
Classes
-
Console
-
Controllers
-
Database
-
Helpers
-
Models
-
ReportWidgets
-
Traits
-
Twig
- ServiceProvider
-
-
Events
-
backend
-
ajax
-
filter
-
form
-
list
-
menu
-
page
-
user
-
-
cms
-
ajax
-
block
-
combiner
-
component
-
object
-
page
-
router
-
template
-
theme
-
-
halcyon
-
datasource
-
-
mailer
-
media
-
model
-
system
-
assets
-
console
-
mirror
-
theme
-
-
reportwidgets
-
settings
- extendConfigFile
-
-
translator
-
-
Library
-
Argon
-
Auth
-
Models
- AuthException
- Manager
-
-
Config
-
Cookie
-
Middleware
-
-
Database
-
Attach
-
Behaviors
-
Concerns
-
Connections
-
Connectors
-
Models
-
Relations
-
Schema
-
Traits
-
Updates
- README
- Builder
- Collection
- DatabaseServiceProvider
- DataFeed
- Dongle
- MemoryCache
- Model
- ModelBehavior
- ModelException
- NestedTreeScope
- Pivot
- QueryBuilder
- SortableScope
- TreeCollection
- Updater
-
-
Events
-
Exception
-
Extension
-
Filesystem
-
Flash
-
Foundation
-
Bootstrap
-
Console
-
Exception
-
Http
-
Middleware
- Kernel
-
-
Providers
- Application
- Maker
-
-
Halcyon
-
Datasource
-
Exception
-
Processors
-
Traits
- README
- Builder
- Collection
- HalcyonServiceProvider
- MemoryCacheManager
- MemoryRepository
- Model
-
-
Html
-
Mail
-
Network
-
Parse
-
Router
-
Scaffold
-
Support
-
Translation
-
- Documentation
- API
- Library
- Halcyon
- README
Rain Halcyon
Halcyon is a file based ORM, and the cousin of Eloquent. The goal of this library is to create a solution for file based object storage that shares the same API as database stored models.
Registering a data source
Datasources reside inside a resolving container called October\Rain\Halcyon\Datasource\Resolver
. The following datasources are supported:
October\Rain\Halcyon\Datasource\FileDatasource
: File based datasource.
Here is an example of registering a datasource called theme1
, then binding the resolver to all models.
use October\Rain\Halcyon\Model; use October\Rain\Filesystem\Filesystem; use October\Rain\Halcyon\Datasource\FileDatasource; use October\Rain\Halcyon\Datasource\Resolver; $datasource = new FileDatasource('/path/to/theme', new Filesystem); $resolver = new Resolver(['theme1' => $datasource]); $resolver->setDefaultDatasource('theme1'); Model::setDatasourceResolver($resolver);
Model example
Inherit the October\Rain\Halcyon\Model
to create a new model:
<?php use October\Rain\Halcyon\Model; class MyPage extends Model { /** * @var array The attributes that are mass assignable. */ protected $fillable = [ 'markup', 'title', ]; /** * @var string The container name associated with the model, eg: pages. */ protected $dirName = 'pages'; }
The following attributes are reserved and have baked in functionality:
- fileName: Reserved for the template file name.
- content: Reserved for the complete file contents.
- settings: Stores the template INI settings.
- markup: Stores the template HTML markup.
- code: Stores the template PHP code (optional).
- mtime: Last modified time.
Now we are free to create a new page:
MyPage::create([ 'fileName' => 'my-file', 'title' => 'Test page', 'markup' => '<p>Hello world!</p>' ]);
Executing the above code will create a new file /path/to/theme/pages/my-file.htm, with the following contents:
title = "Test page" == <p>Hello world!</p>
We can find the page and use it later:
$page = MyPage::find('my-file'); echo '<h1>'.$page->title.'</h1>'; echo $page->markup;
If we change the file name, it will be renamed on the file system too:
// New file path: /path/to/theme/pages/renamed-file.htm $page->fileName = 'renamed-file'; $page->save();