statamic/cms
Statamic is a flat-first CMS built on Laravel and Git for building beautiful, easy-to-manage websites. This package provides the core Composer install for existing Laravel apps; use the Statamic app repo/CLI for new projects.
Installation:
composer require statamic/cms
Requires Laravel 10+ and PHP 8.1+. Follow the official installation guide for full setup.
Publish Assets & Config:
php artisan vendor:publish --provider="Statamic\Providers\StatamicServiceProvider" --tag="config"
php artisan vendor:publish --provider="Statamic\Providers\StatamicServiceProvider" --tag="migrations"
php artisan migrate
First Use Case:
php artisan statamic:collection blog) and a blueprint (php artisan statamic:blueprint blog/entry).title, content) to the blueprint./admin./admin (configured in config/statamic/cp).php artisan statamic:install # Full setup
php artisan statamic:blueprint # Generate blueprints
php artisan statamic:collection # Create collections
php artisan statamic:fieldtype # Register custom fieldtypes
blog, products) with php artisan statamic:collection.
// config/statamic/collections.php
'blog' => [
'title' => 'Blog',
'singular' => 'Entry',
'entries' => 'entries',
'blueprint' => 'blog/entry',
],
# resources/blueprints/collections/blog/entry.yaml
title: Title
content:
type: bard
display: Content
text, bard, assets, relationships) or extend with custom fieldtypes.{{ entries for="blog" sort="date:desc" limit="5" }}
<h2>{{ title }}</h2>
{{ content }}
{{ /entries }}
use Statamic\Entries\Entry;
$entries = Entry::query()
->where('collection', 'blog')
->sortBy('date', 'desc')
->limit(5)
->get();
query {
entries(collection: "blog", sort: "date:desc", limit: 5) {
title
content
}
}
php artisan statamic:upload.use Statamic\Assets\Asset;
$assets = Asset::query()
->where('container', 'images')
->where('folder', 'headers')
->get();
{{ asset_url asset }}
{{ asset_width asset }}x{{ asset_height asset }}
resources/views/vendor/statamic.php artisan statamic:fieldtype my_fieldtype
// app/Fieldtypes/MyFieldtype.php
namespace App\Fieldtypes;
use Statamic\Fieldtypes\Fieldtype;
class MyFieldtype extends Fieldtype {
public static function fieldtype(): string {
return 'my_fieldtype';
}
}
config/statamic/navigation.php or via CP.config/statamic/localization.
'locales' => [
'en' => 'English',
'es' => 'Spanish',
],
{{ locale }} in Antlers or app()->getLocale() in PHP.revisions: true).{{ is_draft }} or entry->isPublished().date field in blueprint.$this->app->singleton('statamic', function () {
return app(Statamic::class);
});
Route::middleware(['web', 'statamic.cp'])->group(function () {
// CP routes
});
Event::listen(EntrySaved::class, function (EntrySaved $event) {
// Handle saved entry
});
{{ livepreview_token }} in Antlers.php artisan statamic:cache.resources/css/statamic.css.php artisan statamic:cache:clear
php artisan statamic:cache:clear --collections
php artisan statamic:optimize.Fieldtype Validation:
validate() and return null or ValidationException.public function validate($value, $field, $errors, $data) {
if (empty($value)) {
$errors->add($field->handle(), 'This field is required.');
}
return $errors;
}
Antlers Parsing:
{{{ or }}}.{{ partial }} carefully—it parses Antlers recursively.config/statamic/antlers.php:
'debug' => env('APP_DEBUG', false),
Asset Handling:
storage/app/assets is writable.Asset::moveUnique() to avoid conflicts:
$asset->moveUnique();
Statamic\Assets\Asset::sanitizeSvg().Localization Quirks:
config/statamic/localization.config/statamic/localization.php:
'date_formats' => [
'en' => 'm/d/Y',
'es' => 'd/m/Y',
],
CP Navigation:
active class in navigation YAML:
items:
- url: /admin/collections/blog
title: Blog
active: true
APP_URL in .env matches CP routes (e.g., APP_URL=https://example.com).Blueprints:
order in YAML to control display:
fields:
title:
order: 1
content:
order: 2
display logic:
fields:
featured_image:
display: "{{ featured == true }}"
Replicator Fields:
handle is unique for each set in the replicator:
fields:
items:
type: replicator
sets:
item:
fields:
title:
handle: title_{{ index }} # Unique handle
GraphQL:
statamic.pro for advanced features (v6.8+).limit: 100).CP Errors:
storage/logs/statamic.log for CP-specific errors.config/statamic/cp.php:
'debug' => true,
**Antlers
How can I help you explore Laravel packages today?