### Create a new Statamic project Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This command first navigates to a specified directory (e.g., '~/Sites') and then uses the globally installed Statamic CLI to create a new Statamic project named 'cyberspace-place'. The installer will prompt for further configuration, such as choosing a blank site or a Starter Kit. ```shell cd ~/Sites && statamic new cyberspace-place ``` -------------------------------- ### Create Post-Install Hook for Statamic Starter Kit Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md Provides an example of a `StarterKitPostInstall.php` class with a `handle` method. This class allows running custom PHP logic after a Statamic Starter Kit has been installed, such as outputting messages to the console or performing additional setup tasks. ```php line('Thanks for installing!'); } } ``` -------------------------------- ### Install Statamic CLI globally Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This command uses Composer to install the Statamic command-line interface globally on your system. This tool is essential for creating and managing Statamic projects from your terminal. ```shell composer global require statamic/cli ``` -------------------------------- ### Install New Statamic Site with Starter Kit (CLI) Source: https://github.com/statamic/docs/blob/master/content/collections/docs/installing-a-starter-kit.md This command utilizes the Statamic CLI Tool to create a completely new Statamic installation and simultaneously integrate a specified Starter Kit. It's the recommended approach for starting fresh projects with a pre-built kit. ```shell statamic new my-site vendor/starter-kit ``` -------------------------------- ### Set Default Installation for Optional Statamic Module Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This YAML configuration sets the default behavior for an optional module's installation prompt. If `default: true`, the module will be installed automatically if the user skips the prompt by pressing enter or during non-interactive installations, streamlining the setup process. ```yaml modules: seo: default: true dependencies: - statamic/seo-pro ``` -------------------------------- ### Statamic Collection Route Pattern Examples Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md Demonstrates various URL routing patterns for Statamic collections, allowing dynamic URL generation based on entry fields such as year, month, day, and slug. These patterns define how entries within a collection will be accessed via URLs. ```APIDOC Example URL | Route Pattern Rule -----------------------------------|----------------------------------- /blog/2021-12-24/merry-christmas | /blog/{year}-{month}-{day}/{slug} /blog/2020/still-bored | /blog/{year}/{slug} /blog/happy-new-year | /blog/{slug} /evergreen-syle | /{slug} ``` -------------------------------- ### Run Initial Development Commands for Vite Source: https://github.com/statamic/docs/blob/master/content/collections/extending-docs/vite-in-addons.md These commands are essential for the initial setup of a Vite-powered Statamic addon. `npm install` fetches all project dependencies, and `npm run dev` starts the Vite development server, enabling hot reloading and resolving 'Vite manifest not found' errors. ```bash npm install npm run dev ``` -------------------------------- ### Install Statamic CLI Globally Source: https://github.com/statamic/docs/blob/master/content/collections/docs/ubuntu.md Installs the Statamic command-line interface tool globally using Composer. This enables the `statamic new` command, which simplifies the process of creating new Statamic projects with an interactive setup wizard. ```shell composer global require statamic/cli ``` -------------------------------- ### Start Local PHP Development Server Source: https://github.com/statamic/docs/blob/master/content/collections/docs/local.md Starts a built-in PHP development server for the Statamic application. This provides a temporary local URL, typically `http://127.0.0.1:8000`, to access your site if a dedicated server like Laravel Valet is not configured. ```cli $ php artisan serve Starting Laravel development server: http://127.0.0.1:8000 ``` -------------------------------- ### Install Statamic Starter Kit from Local Repository Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md Provides the command-line instruction to install a Statamic Starter Kit from a locally configured Composer repository. The `--local` option is used to specify a local installation source, enabling testing of un-published kits. ```bash statamic new kung-fury-dev the-hoff/kung-fury-theme --local ``` -------------------------------- ### Update Ubuntu System Packages Source: https://github.com/statamic/docs/blob/master/content/collections/docs/ubuntu.md Ensures that the package lists and installed packages on the Ubuntu system are up to date before proceeding with Statamic installation, which is a crucial first step for any new setup. ```shell sudo apt-get update sudo apt-get upgrade ``` -------------------------------- ### Create New Statamic Project Source: https://github.com/statamic/docs/blob/master/content/collections/docs/local.md Initializes a new Statamic project in the current directory with the specified project name. This command guides you through choosing a blank site or a Starter Kit and setting up the first super admin user. ```shell statamic new project_name ``` -------------------------------- ### Example Output for GET Parameters Source: https://github.com/statamic/docs/blob/master/content/collections/variables/get.md Illustrates the expected HTML output when accessing the `show` and `hide` GET parameters from the example URL `/about?show=pants&hide=jeggings`. ```html pants pants jeggings ``` -------------------------------- ### Home Page Template Using Blog Listing Partial with Slot Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This Antlers template for the home page demonstrates the use of the 'blog/listing' partial. It passes a 'limit' parameter and uses the partial as a tag pair to inject an 'h2' heading into the partial's slot, showcasing advanced partial usage. ```antlers

Welcome to my CyberSpace Place!

{{ content }} {{ partial:blog/listing limit="5" }}

Recent Blog Posts

{{ /partial:blog/listing }} ``` -------------------------------- ### Simplified Blog Index Template with Partial Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This updated Antlers template for the blog index page uses a partial to display the blog post listing, significantly reducing code duplication. It includes the page title, content, and a call to the 'blog/listing' partial. ```antlers

{{ title }}

{{ content }} {{ partial:blog/listing }} ``` -------------------------------- ### Example YAML Configuration for Reply Source: https://github.com/statamic/docs/blob/master/content/collections/modifiers/starts_with.md Demonstrates a simple YAML structure defining a 'reply' string, which will be used as input for the 'Starts With' modifier. ```yaml reply: Actually, I disagree because this is the internet. ``` -------------------------------- ### Create Statamic Control Panel User via CLI Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This command-line utility creates a new user for the Statamic control panel. It prompts for user details like name and email, and crucially, asks if the user should be a 'super user' for full administrative access. ```bash php please make:user ``` -------------------------------- ### Install Starter Kit into Existing Statamic Site (Artisan) Source: https://github.com/statamic/docs/blob/master/content/collections/docs/installing-a-starter-kit.md To install a Starter Kit into an already existing Statamic site, execute this command from the site's root directory. It leverages Statamic's `php please` command, which is built on Laravel Artisan, to manage the installation process. ```shell php please starter-kit:install vendor-name/starter-kit-name ``` -------------------------------- ### Blog Listing Partial with Slot Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This Antlers partial, named '_listing.antlers.html', encapsulates the blog post display logic. It includes a 'slot' tag, allowing content to be injected into the partial from the calling template, enhancing reusability and flexibility. ```antlers
{{ slot }} {{ collection:blog :limit="limit" }} ... ``` -------------------------------- ### Create Statamic Sandbox Project Source: https://github.com/statamic/docs/blob/master/content/collections/docs/contribution-guide.md Steps to create a new Statamic sandbox project using the `statamic new` command. This sets up a fresh Statamic installation in a separate directory, which is necessary because the `cms` repo itself is a Laravel package and cannot run standalone. ```shell cd sites # [tl! **] statamic new sandbox # [tl! **] Creating a statamic/statamic project at ./sandbox [✔] Statamic has been successfully installed into the sandbox directory. Build something rad! ``` -------------------------------- ### Customize Prompt Text for Optional Statamic Module Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This YAML configuration allows customization of the prompt text displayed to the user when an optional module is presented for installation. It provides a way to use more descriptive or engaging language than the default, enhancing the user experience during kit setup. ```yaml modules: seo: prompt: 'Would you like some awesome SEO with that!?' dependencies: - statamic/seo-pro ``` -------------------------------- ### Display Blog Posts on Index Page Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This Antlers template displays a list of blog posts on the blog index page. It includes the page title, content, and a section looping through all blog posts from the 'blog' collection, showing their title, URL, and date. ```antlers

{{ title }}

{{ content }}
{{ collection:blog }} {{ title }} {{ date }} {{ /collection:blog }}
``` -------------------------------- ### Define Global Statamic Layout with Antlers Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This HTML snippet defines the main layout structure for a Statamic site using Antlers templating. It includes standard HTML boilerplate, integrates Tailwind CSS, and uses `{{ template_content }}` as a placeholder where individual page templates will be injected. ```html {{ title }}
{{ template_content }}
``` -------------------------------- ### Basic Antlers Tag for Fetching Collection Entries Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md A simplified Antlers template snippet illustrating the fundamental usage of the `collection:blog` tag. It shows how to retrieve entries from the 'blog' collection, limit the results to 5, and iterate over them to display the entry's URL and title. ```Antlers {{ collection:blog limit="5" }} {{ title }} {{ /collection:blog }} ``` -------------------------------- ### Global Navigation Bar with Pages Collection Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This Antlers snippet adds a global navigation bar to the layout file. It uses the 'nav:collection:pages' tag to loop through entries in the 'Pages' collection, creating links for each page, including the home page. ```antlers ``` -------------------------------- ### Composer GitHub Authentication Error Example (Starter Kit) Source: https://github.com/statamic/docs/blob/master/content/collections/troubleshooting/composer-and-github-authentication.md Illustrates a common Composer error message indicating a failure to authenticate against github.com, often seen when installing Statamic starter kits. ```cli Could not authenticate against github.com Error installing starter kit [statamic/multisimplicity]. ``` -------------------------------- ### Statamic Site URL Configuration (YAML) Source: https://github.com/statamic/docs/blob/master/content/collections/docs/search.md Example YAML configuration for defining site URLs in Statamic, typically found in `resources/sites.yaml`, enabling multi-language or multi-site setups. ```yaml en: url: / fr: url: /fr/ de: url: /de/ ``` -------------------------------- ### Registering a Basic Statamic Utility Source: https://github.com/statamic/docs/blob/master/content/collections/extending-docs/utilities.md Demonstrates the fundamental steps to register a new utility in Statamic using the `Utility` facade within a service provider's `boot` method. It shows the minimal setup to link a utility handle to a view and includes a basic Blade template example for the utility's content. ```php use Statamic\Facades\Utility; public function boot() { Utility::extend(function () { Utility::register('data_wangjangler')->view('wangjangler.utility'); }); } ``` ```blade @extends('statamic::layout') @section('title', __('Data Wangjangler')) @section('content')

{{ __('Data Wangjangler') }}

@stop ``` -------------------------------- ### Display Single Blog Post Details with Antlers Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This Antlers template snippet is designed for displaying the full details of a single blog entry on its dedicated 'show' page. It automatically accesses entry data such as `title`, `date`, `author:name`, and `content`, demonstrating how Markdown content is rendered as HTML. ```Antlers

{{ title }}

Published on {{ date }} by {{ author:name }}
{{ content }}
``` -------------------------------- ### Verify Composer Installation Source: https://github.com/statamic/docs/blob/master/content/collections/docs/ubuntu.md Checks if Composer has been installed and configured correctly by running the `composer` command. A successful installation will display Composer's version and available commands. ```shell composer ``` -------------------------------- ### Create a New Statamic Site Source: https://github.com/statamic/docs/blob/master/content/collections/docs/laravel-herd.md This command initiates the creation of a new Statamic project using the Statamic CLI. It prompts the user through a setup wizard and creates the new site within the current directory. ```shell statamic new your-project-name ``` -------------------------------- ### Display Recent Blog Posts on Homepage with Antlers Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This Antlers template snippet demonstrates how to integrate a list of the 5 most recent blog entries onto a Statamic homepage. It includes basic HTML structure and styling, utilizing the `collection:blog` tag to fetch data and loop through entries, displaying their title, URL, and date. ```Antlers

Welcome to my CyberSpace Place!

{{ content }}

Recent Blog Posts

{{ collection:blog limit="5" }} {{ title }} {{ date }} {{ /collection:blog }}
``` -------------------------------- ### Statamic Entry Fields Schema Source: https://github.com/statamic/docs/blob/master/content/collections/docs/quick-start-guide.md This section outlines the default fields available when creating a new entry in a Statamic Collection, detailing their purpose, type, and default behavior. It serves as a schema for the data structure of a Statamic entry. ```APIDOC Entry: Fields: Title: string (required) Notes: The required title of the entry Content: string (Markdown) Notes: A simple Markdown field Author: User object Notes: Defaults to whoever is logged in Template: string Notes: When not explicitly set will use the Collection's default Slug: string Notes: Automatically generated off the title until you edit it manually Date: Date Notes: Defaults to today ``` -------------------------------- ### Install Statamic Starter Kit from Composer Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md Installs a Statamic Starter Kit into a new project using its Composer package name. This command fetches and integrates the kit's files and configurations, making it available within the new Statamic instance. ```shell php please starter-kit:install the-hoff/kung-fury-theme ``` -------------------------------- ### Install Statamic Starter Kit with Config Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md Demonstrates how to install a new Statamic project using a Starter Kit and the `--with-config` option. This command ensures that the `starter-kit.yaml` configuration file is included, allowing for future exports and maintaining the development repository's alignment with new Statamic and Laravel versions. ```shell statamic new kung-fury-dev the-hoff/kung-fury-theme --with-config ``` -------------------------------- ### Create New Statamic Application Source: https://github.com/statamic/docs/blob/master/content/collections/docs/ubuntu.md Initializes a new Statamic project named `example.com` in the current directory using the Statamic CLI. This command sets up the basic application structure and necessary files. ```shell statamic new example.com ``` -------------------------------- ### General Command to Export Statamic Starter Kit Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md Executes the export process for a Statamic Starter Kit, copying and arranging all appropriate files into the specified `{export_repo_path}`. This directory is then ready for distribution via platforms like GitHub, GitLab, Bitbucket, or Composer. ```shell php please starter-kit:export {export_repo_path} ``` -------------------------------- ### Using the Get Modifier to Retrieve a Title Source: https://github.com/statamic/docs/blob/master/content/collections/modifiers/get.md These examples show how to use the `get` modifier in Antlers and Blade templates to fetch the 'title' attribute from a content entry identified by `featured_post`. The `get` modifier provides a concise syntax for this common operation. ```antlers {{ featured_post | get('title') }} ``` ```blade {{ Statamic::modify($featured_post)->get('title') }} ``` -------------------------------- ### Initialize Statamic Project as Starter Kit Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This command initializes a new Statamic project, setting it up as a Starter Kit. It creates and configures the necessary `package` directory for the kit's contents, preparing the project for Starter Kit development. ```shell php please starter-kit:init ``` -------------------------------- ### Example HTML Output from Get Modifier Source: https://github.com/statamic/docs/blob/master/content/collections/modifiers/get.md This snippet illustrates the expected HTML output when the `get` modifier successfully retrieves the 'title' from the `featured_post` variable. It shows the plain text result embedded directly into the page. ```html Featured Post Title ``` -------------------------------- ### Example Statamic Documentation URL Source: https://github.com/statamic/docs/blob/master/content/collections/variables/homepage.md This snippet provides an example of a typical URL for the Statamic documentation site, illustrating the format of documentation links. ```html https://docs.statamic.com/ ``` -------------------------------- ### Install Statamic Starter Kit via CLI Source: https://github.com/statamic/docs/blob/master/content/collections/extending-docs/addons.md Demonstrates the command-line interface (CLI) commands used to install a Statamic Starter Kit. These commands are executed in the terminal to set up pre-configured files and settings for a new Statamic project. ```Shell statamic new ``` ```Shell php please starter-kit:install ``` -------------------------------- ### Example Boolean Output Source: https://github.com/statamic/docs/blob/master/content/collections/modifiers/starts_with.md Shows a simple HTML output representing boolean values, which are typical results from conditional checks using the 'Starts With' modifier. ```html true false ``` -------------------------------- ### Example HTML Output from Templating Source: https://github.com/statamic/docs/blob/master/content/collections/fieldtypes/sites.md An example of the HTML output generated by the templating examples, showing a list of items. ```html ``` -------------------------------- ### Install Composer Globally Source: https://github.com/statamic/docs/blob/master/content/collections/docs/ubuntu.md This two-step process first downloads the Composer installer script using curl, then moves the `composer.phar` file to a globally accessible directory (`/usr/local/bin`) and sets execute permissions, making Composer available system-wide. ```curl curl -sS https://getcomposer.org/installer | php ``` ```shell sudo mv composer.phar /usr/local/bin/composer sudo chmod +x /usr/local/bin/composer ``` -------------------------------- ### Configure User Selection for Multiple Optional Modules Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This YAML configuration enables the user to select only one from a set of predefined optional modules. It uses an `options` object to group different choices, each with its own `export_paths`, allowing for flexible front-end framework integration or similar choices. ```yaml modules: js: options: vue: export_paths: - resources/js/vue.js react: export_paths: - resources/js/react.js mootools: export_paths: - resources/js/mootools.js ``` -------------------------------- ### YAML Data Setup for Add Modifier Examples Source: https://github.com/statamic/docs/blob/master/content/collections/modifiers/add.md Defines initial integer values for 'books' and 'magazines' variables, which are used as inputs for the 'Add' modifier examples. ```yaml books: 5 magazines: 10 ``` -------------------------------- ### Export Statamic Starter Kit to a Directory Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md Exports the current Statamic Starter Kit's relevant files and configurations to a specified directory. This directory will serve as the distributable package for the Starter Kit, ready for version control and redistribution. ```shell php please starter-kit:export ../kung-fury-theme ``` -------------------------------- ### Install Statamic CLI Globally Source: https://github.com/statamic/docs/blob/master/content/collections/docs/local.md Installs the Statamic Command Line Interface (CLI) tool globally using Composer. This allows you to run `statamic` commands from any directory on your system. ```shell composer global require statamic/cli ``` -------------------------------- ### API Endpoint: Get Collection Entries Source: https://github.com/statamic/docs/blob/master/content/collections/docs/rest-api.md Documents the `GET /api/collections/{collection}/entries` endpoint, which retrieves all entries within a specified collection. Notes that it serves from all sites in a multi-site setup, with an option to filter by `site`. ```APIDOC GET /api/collections/{collection}/entries Description: Gets entries within a collection. Parameters: collection: (path) The handle of the collection. filter[site]: (query, optional) Limit fetched data to a specific site (e.g., `&filter[site]=fr`). Returns: JSON object with 'data' array of entries, 'links', and 'meta'. ``` ```json { "data": [ { "title": "My First Day" } ], "links": {...}, "meta": {...} } ``` -------------------------------- ### Add Local Repository Path to Composer Global Config Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md Explains how to add a local repository path to Composer's global `config.json` file. This allows testing Statamic Starter Kits directly from a local development repository before publishing, facilitating rapid iteration. ```json { "repositories": [ { "type": "path", "url": "/Users/hasselhoff/kung-fury-theme" } ] } ``` -------------------------------- ### Start Docker containers with Laravel Sail in foreground Source: https://github.com/statamic/docs/blob/master/content/collections/docs/docker.md Executes the Sail 'up' command to start all Docker containers defined in the project's `docker-compose.yml` file. The containers run in the foreground, displaying logs directly in the terminal. ```shell ./vendor/bin/sail up ``` -------------------------------- ### Example Asset Path String Source: https://github.com/statamic/docs/blob/master/content/collections/variables/path.md An example of a typical relative path string for an asset, showing the directory and filename within the asset container. ```html img/black-bear-cubs.jpg ``` -------------------------------- ### Start Docker containers with Laravel Sail in detached mode Source: https://github.com/statamic/docs/blob/master/content/collections/docs/docker.md Executes the Sail 'up' command with the '-d' flag to start all Docker containers in the background (detached mode). This allows the terminal to be used for other commands while the containers continue to run. ```shell ./vendor/bin/sail up -d ``` -------------------------------- ### Configure Composer for Local Starter Kit Development Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This JSON snippet shows how to modify a `composer.json` file to include a local Starter Kit as a path repository. This configuration is essential for developing and testing the Starter Kit locally and enabling future updates by Composer. ```json { "name": "statamic/statamic", "require": [ "the-hoff/kung-fury-theme": "dev-master" ], "repositories": [ { "type": "path", "url": "package" } ] } ``` -------------------------------- ### Execute Custom Commands After Statamic Installation Source: https://github.com/statamic/docs/blob/master/content/collections/extending-docs/addons.md Demonstrates how to run additional Artisan commands or custom code immediately after Statamic has been installed. This is achieved by using the `Statamic::afterInstalled` method within an addon's `bootAddon` method, allowing for automation of setup tasks. ```php public function bootAddon() { Statamic::afterInstalled(function ($command) { $command->call('some:command'); }); } ``` -------------------------------- ### Configure Optional Module with Export Paths and Dependencies Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This YAML configuration shows how to define an optional module that includes both specific export paths and Composer dependencies. It allows for granular control over what files and packages are included when a user opts into the module, ensuring all necessary components are present. ```yaml modules: seo: export_paths: - resources/css/seo.css dependencies: - statamic/seo-pro ``` -------------------------------- ### Define Dictionary Get Method for Item Retrieval Source: https://github.com/statamic/docs/blob/master/content/collections/extending-docs/dictionaries.md Shows the `get()` method, which accepts a value (one of the option's keys) and should return an `Item` instance. This example demonstrates fetching product data based on the key and constructing an `Item` with its label and additional data. ```php public function get(string $key): ?Item { $product = Product::find($key); return new Item($key, $product->name, [ 'price' => $product->price, 'sku' => $product->sku, ]); } ``` -------------------------------- ### Install PHP and Essential Modules for Statamic Source: https://github.com/statamic/docs/blob/master/content/collections/docs/ubuntu.md Installs PHP 8.1+ and necessary modules like common, FPM, JSON, mbstring, zip, cli, XML, tokenizer, and curl. These modules are fundamental for Statamic to function correctly and handle various operations. ```shell sudo apt install php-common php-fpm php-json php-mbstring zip unzip php-zip php-cli php-xml php-tokenizer php-curl -y ``` -------------------------------- ### Get Mount URL for a Collection Source: https://github.com/statamic/docs/blob/master/content/collections/tags/mount_url.md This example demonstrates how to retrieve the URL for a collection's mount entry using the `mount_url` tag with a specified handle. ```antlers Read Our Blog ``` ```blade Read Our Blog ``` -------------------------------- ### Configure composer.json for Statamic Starter Kit Publishing Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md Details the necessary `composer.json` configuration for publishing a Statamic Starter Kit. It specifies setting the `name` property to match the Composer/GitHub organization and repository name, along with Statamic-specific `extra` fields for display name and description. ```json { "name": "the-hoff/kung-fury-theme", "extra": { "statamic": { "name": "Kung Fury Theme", "description": "Kung Fury Theme Starter Kit" } } } ``` -------------------------------- ### Customize Prompt and Labels for Module Selection Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This YAML configuration provides extensive customization for the module selection prompt. It allows setting a custom main prompt, text for skipping the selection, and individual labels for each module option, enhancing user experience and clarity during the installation process. ```yaml modules: js: prompt: 'Would you care for some JS?' skip_option: 'No, thank you!' options: vue: label: 'VueJS' export_paths: - resources/js/vue.js react: label: 'ReactJS' export_paths: - resources/js/react.js mootools: label: 'MooTools (will never die!)' export_paths: - resources/js/mootools.js ``` -------------------------------- ### Modify Composer Scripts for Statamic Integration Source: https://github.com/statamic/docs/blob/master/content/collections/docs/laravel.md This JSON snippet shows how to update your `composer.json` file to include Statamic's pre-update and post-autoload-dump scripts. These scripts automate crucial setup tasks, such as package discovery and Statamic's internal installation processes, ensuring proper integration within your Laravel application. ```json "scripts": { "pre-update-cmd": [ "Statamic\\Console\\Composer\\Scripts::preUpdateCmd" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi", "@php artisan statamic:install --ansi" ] } ``` -------------------------------- ### Skip User Confirmation for Optional Statamic Module Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This YAML configuration allows a specific optional module to be installed without prompting the user for confirmation. Setting `prompt: false` can be used to organize larger Starter Kit configurations by always including certain modules, simplifying the installation flow for users. ```yaml modules: seo: prompt: false ``` -------------------------------- ### Get Form Submissions by Handle in PHP Source: https://github.com/statamic/docs/blob/master/content/collections/repositories/form-submission-repository.md This example shows how to retrieve all form submissions associated with a specific form handle using the `whereForm` method of the `FormSubmission` facade. ```php FormSubmission::whereForm('postbox'); ``` -------------------------------- ### Get Mount URL using Shorthand Syntax Source: https://github.com/statamic/docs/blob/master/content/collections/tags/mount_url.md This example shows the shorthand syntax for retrieving a collection's mount URL, where the collection handle is passed as a direct argument to the tag. ```antlers Read Our Blog ``` ```blade Read Our Blog ``` -------------------------------- ### Define an Optional Module in Statamic Starter Kit Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This YAML configuration demonstrates how to define an optional module, such as an 'seo' module, within a Statamic Starter Kit. It allows users to choose whether to install specific dependencies associated with the module, providing flexibility during kit installation. ```yaml modules: seo: dependencies: - statamic/seo-pro ``` -------------------------------- ### Configure Statamic Starter Kit Export Paths Source: https://github.com/statamic/docs/blob/master/content/collections/docs/creating-a-starter-kit.md This YAML configuration defines the specific files and directories that should be included when a Statamic Starter Kit is exported. It ensures that only the designated content, configuration files, resources, and public assets are packaged for distribution, preventing unnecessary files from being included. ```yaml export_paths: - content - config/filesystems.php - config/statamic/assets.php - resources/blueprints - resources/css/site.css - resources/views - public/assets - public/css - package.json - tailwind.config.js - webpack.mix.js ``` -------------------------------- ### Retrieve Submissions for a Specific Form Source: https://github.com/statamic/docs/blob/master/content/collections/repositories/form-repository.md This example demonstrates how to get all submissions for a specific form using its handle. The `submissions()` method, called on a retrieved form instance, returns a `Collection` of form submissions. ```php Form::find('postbox')->submissions(); ``` -------------------------------- ### API Endpoint: Get All Forms Source: https://github.com/statamic/docs/blob/master/content/collections/docs/rest-api.md Retrieves a list of all forms defined in Statamic. Each form entry includes its handle, title, a summary of its fields, and its dedicated API URL, as shown in the example JSON. ```APIDOC GET /api/forms { "data": [ { "handle": "contact", "title": "Contact", "fields": { "name": {...}, "email": {...}, "inquiry": {...} }, "api_url": "http://example.com/api/forms/contact", }, { "handle": "newsletter", "title": "Subscribe to Newsletter", "fields": { "email": {...} }, "api_url": "http://example.com/api/forms/newsletter", } ], } ``` -------------------------------- ### Set up Statamic Documentation for Local Development Source: https://github.com/statamic/docs/blob/master/README.md This snippet provides the necessary shell commands to install dependencies and configure the Statamic documentation project for local development. It assumes the project is being served using Laravel Valet and has been cloned into the `~/Sites/docs` directory. ```Shell composer install npm install npm run dev cp .env.example .env php artisan key:generate ``` -------------------------------- ### API Endpoint: Get All Globals Source: https://github.com/statamic/docs/blob/master/content/collections/docs/rest-api.md Retrieves a list of all global sets configured in Statamic. Each global set includes its handle, API URL, and associated variables, as demonstrated in the example JSON response. ```APIDOC GET /api/globals { "data": [ { "handle": "global", "api_url": "http://example.com/api/globals/global", "foo": "bar", }, { "handle": "another", "api_url": "http://example.com/api/globals/another", "baz": "qux", } ], } ``` -------------------------------- ### Configure Nginx Server Block for Website Source: https://github.com/statamic/docs/blob/master/content/collections/docs/ubuntu.md Provides a recommended Nginx server block configuration for serving a website, including directives for listening on port 80, defining the server name, setting the document root, adding security headers, handling index files, and integrating with PHP-FPM. It also includes rules for static files, error pages, and denying access to hidden files. Remember to replace 'example.com' with your actual domain and ensure the PHP-FPM socket path matches your installed PHP version. ```nginx server { listen 80; server_name example.com; // [tl! highlight:1] root /var/www/example.com/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; index index.html index.htm index.php; charset utf-8; set $try_location @static; if ($request_method != GET) { set $try_location @not_static; } if ($args ~* "live-preview=(.*)") { set $try_location @not_static; } location / { try_files $uri $try_location; } location @static { try_files /static${uri}_$args.html $uri $uri/ /index.php?$args; } location @not_static { try_files $uri /index.php?$args; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.(?!well-known).* { deny all; } } ``` -------------------------------- ### API Endpoint: Get All Taxonomy Terms Source: https://github.com/statamic/docs/blob/master/content/collections/docs/rest-api.md Retrieves a list of all terms within a specified taxonomy. This endpoint supports filtering and provides paginated results, including an example JSON response structure. ```APIDOC GET /api/taxonomies/{taxonomy}/terms { "data": [ { "title": "Music", } ], "links": {...}, "meta": {...} } ``` -------------------------------- ### Retrieve Current Layout Name Source: https://github.com/statamic/docs/blob/master/content/collections/variables/current_layout.md This snippet shows how to get the name of the layout currently being rendered. It provides examples for both Antlers and Blade templating engines, allowing developers to dynamically reference or display the active layout. ```antlers {{ current_layout }} ``` ```blade {{ $current_layout }} ``` -------------------------------- ### API Endpoint: Get Single Taxonomy Term Source: https://github.com/statamic/docs/blob/master/content/collections/docs/rest-api.md Retrieves a single taxonomy term by its unique slug within a specified taxonomy. The response includes the term's data, as shown in the example JSON structure. ```APIDOC GET /api/taxonomies/{taxonomy}/terms/{slug} { "data": { "title": "My First Day" } } ``` -------------------------------- ### Initialize New User Instance Source: https://github.com/statamic/docs/blob/master/content/collections/repositories/user-repository.md Starts the process of creating a new user by instantiating a `User` object with a required email address using the `make` method. ```php $user = User::make()->email('john@smith.com'); ``` -------------------------------- ### Substr Modifier Usage in Antlers and Blade Source: https://github.com/statamic/docs/blob/master/content/collections/modifiers/substr.md Demonstrates the application of the 'substr' modifier in both Antlers and Blade templating languages. Examples include extracting substrings with positive and negative start positions, and specifying a length. ```antlers {{ string | substr(0, 3) }} {{ string | substr(4, 4) }} {{ string | substr(-8, 8) }} ``` ```blade {{ Statamic::modify($string)->substr([0, 3]) }} {{ Statamic::modify($string)->substr([4, 4]) }} {{ Statamic::modify($string)->substr([-8, 8]) }} ``` -------------------------------- ### Stop all Docker containers managed by Laravel Sail Source: https://github.com/statamic/docs/blob/master/content/collections/docs/docker.md Executes the Sail 'stop' command to gracefully shut down all Docker containers that were started by Sail for the current project. This frees up system resources and stops the running application. ```shell ./vendor/bin/sail stop ``` -------------------------------- ### Fetching Content by URI with `get_content` Tag Source: https://github.com/statamic/docs/blob/master/content/collections/tags/get_content.md Example of using the `get_content` tag to retrieve and display structured content from a specific entry identified by its URI. This is useful for hard-coding dynamic content, such as company staff information, directly into a template. ```antlers {{ get_content from="/about/company" }} {{ staff }}
{{ name }}

{{ name }}, {{ job_title }}

{{ /staff }} {{ /get_content }} ``` ```blade @foreach ($staff as $member)
{{ $member->name }}

{{ $member->name }}, {{ $member->job_title }}

@endforeach
```