-
Notifications
You must be signed in to change notification settings - Fork 48
2.0 Proposal #299
Description
Phile 2.0
Lately I have been using Laravel and Slim and have noticed some nice things we can steal. It has been a while since I used Phile, but I have been using it for the past couple of weeks and noticed some of the missing or awkward choices.
This is my pitch for 2.0. This is simply a proposal that is open for discussion, not a demand or order for a particular direction.
Use default composer dir
Right now we have a custom vendor setup as /lib/vendor. I think this should be removed and just use the default /vendor.
All things composer
Move the Phile core into a composer package, and use a composer create-project command to generate a skeleton app that has everything setup.
This would remove the need to manually set the encryptionKey or do a setupCheck. This could even be interactive like composer init.
All plugins in composer
Move all the plugins onto packagist. Plugins are installed into /vendor using composer install/require.
Then we use something like the service provider in Laravel to load plugins by their class name.
For example:
$config['plugins']['phile\\phpFastCache'] = ['active' => true];
$config['plugins']['phile\\simpleFileDataPersistence'] = ['active' => true];
$config['plugins']['phile\\filterByKey'] = ['active' => false];
$config['plugins']['warpaintmedia\\twitterPlugin'] = ['active' => true];Would become something like:
$config['plugins'] = [
Phile\Plugin\PhpFastCache::class,
Phile\Plugin\SimpleFileDataPersistence::class,
// Phile\Plugin\FilterByKey::class,
WarpaintMedia\Phile\TwitterPlugin::class,
// ...
];To disable a plugin, simply remove it from the list or comment it out. I describe plugin config in the next section.
Remove default_config and config
Remove both config files. Add a /config folder and load all files inside it.
Then we can have our plugin configs in that folder, but also split up by name.
Any default Phile config stuff would be in the Phile Core package.
Plugins have routes
Add the ability to set a route for the plugin to be reached at.
This means a plugin could be used almost like a controller. Useful for AJAX/Form submission stuff.
Pages as a collection
The pages array or class should instead be a Collection.
This allows easy filtering, sorting, reducing, and searching, but as part of the Pages object. This makes manipulating the pages array in a plugin (but also in Core) much easier.
Add a /public folder
Instead of having a /protected folder, we should just have a /public folder. Everything else can be locked down.
This can be used to store uploads or arbitrary things that don't belong in /content or /themes.
Helper functions in templates
These would be really simple to add in Twig.
{{ url('/some-page') }}instead of{{ base_url }}/some-page{{ theme('/css/style.css') }}instead of{{ theme_url }}/css/style.css{{ render('/hidden/file.md') }}would render a file in the/contentdirectory.{{ route('pluginName.pluginRoute') }}would be able to resolve a plugin route to a real Phile route{{ meta('a_meta_key', 'default value if missing') }}would allow you to fetch meta, or have default meta
In the end, I think these changes would make Phile much nicer. It may be a little more advanced, but I think the benefits outweight the downsides.
Anyone have any comments on this?