All Projects → rsanchez → Craft Cli

rsanchez / Craft Cli

Command line interface for Craft CMS 2.

Projects that are alternatives of or similar to Craft Cli

craft-entriessubset
Craft field type plugin that extends the core Entries field type to give extra settings
Stars: ✭ 27 (-81.12%)
Mutual labels:  craft, craftcms
Simplemap
A beautifully simple map field type for Craft CMS.
Stars: ✭ 136 (-4.9%)
Mutual labels:  craftcms, craft
Awesome
A collection of awesome Craft CMS plugins, articles, resources and shiny things.
Stars: ✭ 449 (+213.99%)
Mutual labels:  craftcms, craft
Craft Preparse Field
Field type that parses twig when an element is saved.
Stars: ✭ 103 (-27.97%)
Mutual labels:  craftcms, craft
Craft Async Queue
Async Queue Handler for Craft 3
Stars: ✭ 80 (-44.06%)
Mutual labels:  craftcms, craft
craft-instagram-feed
Craft CMS plugin to receive Instragram feed data as variable in templates
Stars: ✭ 25 (-82.52%)
Mutual labels:  craft, craftcms
Craftcms Docker
Craft3/Craft2 CMS Docker base (Nginx, PHP-FPM 8, PostgreSQL/MariaDB, Redis)
Stars: ✭ 99 (-30.77%)
Mutual labels:  craftcms, craft
padstone
Padstone is a Craft CMS starter kit with a curated configuration, Boilerplate templates, and handpicked plugins.
Stars: ✭ 18 (-87.41%)
Mutual labels:  craft, craftcms
Craft Inventory
Inventory plugin for Craft CMS
Stars: ✭ 65 (-54.55%)
Mutual labels:  craftcms, craft
Craft Copy
Deployment tools for Craft on fortrabbit
Stars: ✭ 64 (-55.24%)
Mutual labels:  craftcms, craft
picpuller-for-craft3
Pic Puller for Craft 3 lets authorized users pull in their Instagram media into Craft.
Stars: ✭ 12 (-91.61%)
Mutual labels:  craft, craftcms
Buttonbox
A collection of utility field types for Craft
Stars: ✭ 94 (-34.27%)
Mutual labels:  craftcms, craft
craft-cpjs
Control Panel JS plugin for Craft CMS
Stars: ✭ 42 (-70.63%)
Mutual labels:  craft, craftcms
craft-plugin-mix
Helper plugin for Laravel Mix in Craft CMS templates
Stars: ✭ 50 (-65.03%)
Mutual labels:  craft, craftcms
molecule
⚛️ Grab Twig components, CSS and JS files outside the primary template folder
Stars: ✭ 20 (-86.01%)
Mutual labels:  craft, craftcms
Craft Boilerplate
Our standard project template for new Craft CMS websites
Stars: ✭ 44 (-69.23%)
Mutual labels:  craftcms, craft
craft-bulkedit
Bulk edit any set of elements
Stars: ✭ 22 (-84.62%)
Mutual labels:  craft, craftcms
visor
🕶 A simple admin overlay to get to the relevant areas of the Craft CMS control panel.
Stars: ✭ 25 (-82.52%)
Mutual labels:  craft, craftcms
Craft Brief
Quick, easy, and customizable user-group notifications for Craft CMS.
Stars: ✭ 47 (-67.13%)
Mutual labels:  craftcms, craft
Craft.patrol
Patrol simplifies SSL and maintenance routing for sites built with Craft
Stars: ✭ 91 (-36.36%)
Mutual labels:  craftcms, craft

Craft CLI

Command line interface for Craft CMS.

Installation

If you are on Mac, you should install via Homebrew.

brew tap rsanchez/homebrew-craft-cli
brew install craft-cli

Otherwise, you should download the phar: https://github.com/rsanchez/craft-cli/releases/latest

php craft.phar <your:command>

See Composer Installation for alternate ways to install.

Usage

If you are using a multi-environment config, you must specify your environment either using the --environment= flag on your commands, or set the CRAFT_ENVIRONMENT env variable.

craft --environment="mysite.dev" show:config
CRAFT_ENVIRONMENT="mysite.dev" craft show:config

Craft CLI is dotenv aware, and will automagically load environment variables from a .env file in your project root (path can be customised via .craft-cli.php). You may set your Craft environment by setting a CRAFT_ENVIRONMENT variable in your .env file.

Commands

Assets Pull

Pull Asset files from a remote environment.

craft assets:pull --ssh-host=your.remote.server.com --ssh-user=yourUserName yourRemoteEnvironmentName

Assets Push

Push Asset files to a remote environment

craft assets:push --ssh-host=your.remote.server.com --ssh-user=yourUserName yourRemoteEnvironmentName

Clear Cache

Clear all Craft caches.

craft clear:cache

Select which cache(s) to clear from an interactive list.

craft clear:cache -s

Console

Start an interactive shell.

craft console

DB Backup

Backup your database to craft/storage/backups.

craft db:backup

Backup your database to the specified path.

craft db:backup ./backup.sql

DB Create

Create a database

craft db:create --host=localhost --port=3306 --name=yourDbName --user=yourUserName --password=yourPassword

DB Pull

Pull a remote database to the local database.

craft db:pull --ssh-host=your.remote.server.com --ssh-user=yourUserName --force yourRemoteEnvironmentName

DB Push

Push your local database to a remote database.

craft db:push --ssh-host=your.remote.server.com --ssh-user=yourUserName --force yourRemoteEnvironmentName

DB Restore

Restore the database from the most recent backup from craft/storage/backups.

craft db:restore --force

Restore the database from the specified .sql file.

craft db:restore --force ./backup.sql

Download Craft

Download Craft to the current directory.

craft download

Create the specified directory and download Craft into it.

craft download path/to/directory

Generate Command

Generate a custom command file in the specified directory.

craft generate:command your:custom_command ./commands/

Generate a custom command file with a namespace.

craft generate:command --namespace="YourSite\Command" your:custom_command ./src/YourSite/Command/

Generate a custom command with arguments and options.

craft generate:command --options --arguments your_command ./commands/

Help

Display information about a command and its arguments/options.

craft help <command>

Init

Create an .craft-cli.php config file in the current directory

craft init

This config file is only necessary if you if you are using Custom Commands or have renamed your craft folder.

Install Craft

Download and install Craft to the current directory.

craft install

Create the specified directory and install Craft into it.

craft install path/to/directory

Install Plugin

Install a plugin from a GitHub repository.

craft install:plugin pixelandtonic/ElementApi

List

List the available commands.

craft list

Rebuild Search Indexes

craft rebuild:searchindexes

Run Tasks

Run all pending tasks.

craft run:tasks

Reset "running" (stalled) tasks and then run all tasks.

craft run:tasks --reset-running

Reset failed tasks and then run all tasks.

craft run:tasks --reset-failed

Show Config

Show all config items.

craft show:config

Show the specified config item.

craft show:config db.user

Tail

Show a tail of craft.log

craft tail

Update Asset Indexes

craft update:assetsindexes

Configuration

Craft CLI can be configured in two ways. You may use the craft init command to generate a .craft-cli.php file. Or, if you have installed Craft CLI via composer, you may add an extra object to your composer.json and a craft-cli object within the extra object:

{
    "extra": {
        "craft-cli": {
            "commandDirs": {
                "\\Your\\Namespace": "path/to/commands/"
            }
        }
    }
}

Custom Commands

Craft CLI custom commands are Symfony Console Command objects. You can add custom commands to your .craft-cli.php or composer.json config by adding a namespace and folder path to the commandDirs object.

You can generate a custom command file using the craft generate:command command.

Troubleshooting

Your command-line PHP cannot connect to MySQL

You can test this by running this at the command line (change the DB credentials to your actual credentials):

php -r "var_dump(@mysql_connect('hostname', 'username', 'password', 'database_name'));"

If this prints false, then you know that your CLI PHP is not configured to connect to your database. This is frequently caused by an incorrect default MySQL socket setting.

If you are running MAMP, for instance, and are using the stock Mac OS command-line PHP, you will not be able to connect out-of-the-box. You will need to edit your /etc/php.ini (or wherever your php.ini file is located) file and change the mysql.default_socket and/or the mysqli.default_socket to /Applications/MAMP/tmp/mysql/mysql.sock.

Composer Installation

You can install globally:

composer global require craft-cli/cli

Make sure your global composer installation is added to your PATH in your ~/.bash_profile (or ~/.profile or ~/.bashrc or ~/.zshrc) so that you may run the binary from the command line:

export PATH=~/.composer/vendor/bin:$PATH

Or, you can install on a per project basis, rather than globally to your host system.

composer require craft-cli/cli

Then the command would be found in your vendor/bin folder, so you'd run this at your command line:

vendor/bin/craft <your:command>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].