2017-10-10 11:15:24 +02:00
# Command Line Interface (CLI)
Strapi comes with a full featured Command Line Interface (CLI) which lets you scaffold and manage your project in seconds.
2019-07-18 19:28:52 +02:00
---
2017-10-10 11:15:24 +02:00
## strapi new
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Create a new project
```bash
strapi new < name >
2019-02-01 15:19:22 +01:00
options: [--dev|--debug|--quickstart|--dbclient=< dbclient > --dbhost=< dbhost > --dbport=< dbport > --dbname=< dbname > --dbusername=< dbusername > --dbpassword=< dbpassword > --dbssl=< dbssl > --dbauth=< dbauth > --dbforce]
2017-10-10 11:15:24 +02:00
```
- **strapi new & #60 ; name& #62 ; **< br />
2017-10-12 11:22:28 +02:00
Generates a new project called ** & #60 ; name& #62 ; ** and installs the default plugins through the npm registry.
2017-10-10 11:15:24 +02:00
- **strapi new & #60 ; name& #62 ; --dev**< br />
2017-10-12 11:22:28 +02:00
Generates a new project called ** & #60 ; name& #62 ; ** and creates symlinks for the `./admin` folder and each plugin inside the `./plugin` folder. It means that the Strapi's development workflow has been set up on the machine earlier.
2019-02-01 15:19:22 +01:00
2018-12-28 17:05:16 +01:00
- **strapi new & #60 ; name& #62 ; --debug**< br />
Will display the full error message if one is fired during the database connection.
2017-10-12 11:22:28 +02:00
2019-02-01 15:19:22 +01:00
- **strapi new & #60 ; name& #62 ; --quickstart**< br />
2019-07-18 19:28:52 +02:00
Use the quickstart system to create your app.
2019-02-01 15:19:22 +01:00
2018-12-24 15:39:51 +05:30
- **strapi new & #60 ; name& #62 ; --dbclient=& #60 ; dbclient& #62 ; --dbhost=& #60 ; dbhost& #62 ; --dbport=& #60 ; dbport& #62 ; --dbname=& #60 ; dbname& #62 ; --dbusername=& #60 ; dbusername& #62 ; --dbpassword=& #60 ; dbpassword& #62 ; --dbssl=& #60 ; dbssl& #62 ; --dbauth=& #60 ; dbauth& #62 ; --dbforce**< br />
2019-01-03 14:23:05 +01:00
2019-07-05 03:05:36 +02:00
Generates a new project called ** & #60 ; name& #62 ; ** and skip the interactive database configuration and initialize with these options.
2019-07-18 19:28:52 +02:00
2018-12-14 11:31:41 +01:00
- **& #60 ; dbclient& #62 ; ** can be `mongo` , `postgres` , `mysql` .
- **& #60 ; dbssl& #62 ; ** and ** & #60 ; dbauth& #62 ; ** are available only for `mongo` and are optional.
2019-02-01 15:19:22 +01:00
- **--dbforce** Allows you to overwrite content if the provided database is not empty. Only available for `postgres` , `mysql` , and is optional.
2018-02-06 20:42:30 +01:00
2018-12-14 11:31:41 +01:00
See the [CONTRIBUTING guide ](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md ) for more details.
2017-10-10 11:15:24 +02:00
2018-12-14 11:31:41 +01:00
## strapi start
2019-07-18 19:28:52 +02:00
2018-12-14 11:31:41 +01:00
Start a Strapi application.
That provide some feature like auto restart when you update a file in you application (except public files).
If you don't use `strapi start` to start you application some plugin that use `strapi.reload();` (content-type-builder plugin for example) can break or not work well.
2017-10-10 11:15:24 +02:00
## strapi generate:api
2019-07-18 19:28:52 +02:00
2017-10-12 11:22:28 +02:00
Scaffold a complete API with its configurations, controller, model and service.
2017-10-10 11:15:24 +02:00
```bash
strapi generate:api < name > [< attribute:type > ]
options: [--tpl < name > |--plugin < name > ]
```
- **strapi generate:api & #60 ; name& #62 ; **< br />
Generates an API called ** & #60 ; name& #62 ; ** in the `./api` folder at the root of your project.
- **strapi generate:api & #60 ; name& #62 ; & #60 ; attribute:type& #62 ; **< br />
Generates an API called ** & #60 ; name& #62 ; ** in the `./api` folder at the root of your project. The model will already contain an attribute called ** & #60 ; attribute& #62 ; ** with the type property set to ** & #60 ; type& #62 ; **.
Example: `strapi generate:api product name:string description:text price:integer`
- **strapi generate:api & #60 ; name& #62 ; --plugin & #60 ; plugin& #62 ; **< br />
Generates an API called ** & #60 ; name& #62 ; ** in the `./plugins/<plugin>` folder.
2017-10-12 11:22:28 +02:00
Example: `strapi generate:api product --plugin content-manager`
2017-10-10 11:15:24 +02:00
- **strapi generate:api & #60 ; name& #62 ; --tpl & #60 ; template& #62 ; **< br />
2017-10-12 11:22:28 +02:00
Generates an API called ** & #60 ; name& #62 ; ** in the `./api` folder which works with the given ** & #60 ; template& #62 ; **. By default, the generated APIs are based on Mongoose.
Example: `strapi generate:api product --tpl bookshelf`
2017-10-10 11:15:24 +02:00
2018-10-01 12:19:34 +02:00
::: note
2019-07-05 03:05:36 +02:00
The first letter of the filename will be uppercase.
2018-10-01 12:19:34 +02:00
:::
2017-10-10 11:15:24 +02:00
## strapi generate:controller
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Create a new controller
```bash
strapi generate:controller < name >
options: [--api < name > |--plugin < name > ]
```
- **strapi generate:controller & #60 ; name& #62 ; **< br />
Generates an empty controller called ** & #60 ; name& #62 ; ** in the `./api/<name>/controllers` folder.
Example: `strapi generate:controller category` will create the controller at `./api/category/controllers/Category.js` .
- **strapi generate:controller & #60 ; name& #62 ; --api & #60 ; api& #62 ; **< br />
Generates an empty controller called ** & #60 ; name& #62 ; ** in the `./api/<api>/controllers` folder.
Example: `strapi generate:controller category --api product` will create the controller at `./api/product/controllers/Category.js` .
- **strapi generate:controller & #60 ; name& #62 ; --plugin & #60 ; plugin& #62 ; **< br />
Generates an empty controller called ** & #60 ; name& #62 ; ** in the `./plugins/<plugin>/controllers` folder.
2018-10-01 12:19:34 +02:00
::: note
2019-07-05 03:05:36 +02:00
The first letter of the filename will be uppercase.
2018-10-01 12:19:34 +02:00
:::
2017-10-10 11:15:24 +02:00
## strapi generate:model
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Create a new model
```bash
strapi generate:model < name > [< attribute:type > ]
options: [--api < name > |--plugin < name > ]
```
- **strapi generate:model & #60 ; name& #62 ; **< br />
Generates an empty model called ** & #60 ; name& #62 ; ** in the `./api/<name>/models` folder. It will create two files.
The first one will be ** & #60 ; name& #62 ; .js** which contains your lifecycle callbacks and another ** & #60 ; name& #62 ; .settings.json** that will list your attributes and options.
Example: `strapi generate:model category` will create these two files `./api/category/models/Category.js` and `./api/category/models/Category.settings.json` .
- **strapi generate:model & #60 ; name& #62 ; & #60 ; attribute:type& #62 ; **< br />
Generates an empty model called ** & #60 ; name& #62 ; ** in the `./api/<name>/models` folder. The file ** & #60 ; name& #62 ; .settings.json** will already contain a list of attribute with their associated ** & #60 ; type& #62 ; **.
Example: `strapi generate:model category name:string description:text` will create these two files `./api/category/models/Category.js` and `./api/category/models/Category.settings.json` . This last file will contain two attributes `name` with the type `string` and `description` with type `text` .
- **strapi generate:model & #60 ; name& #62 ; --api & #60 ; api& #62 ; **< br />
Generates an empty model called ** & #60 ; name& #62 ; ** in the `./api/<api>/models` folder.
Example: `strapi generate:model category --api product` will create these two files:
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
- `./api/product/models/Category.js`
- `./api/product/models/Category.settings.json` .
2019-07-18 19:28:52 +02:00
* **strapi generate:model & #60 ; name& #62 ; --plugin & #60 ; plugin& #62 ; **< br />
2017-10-10 11:15:24 +02:00
Generates an empty model called ** & #60 ; name& #62 ; ** in the `./plugins/<plugin>/models` folder.
2018-10-01 12:19:34 +02:00
::: note
2019-07-05 03:05:36 +02:00
The first letter of the filename will be uppercase.
2018-10-01 12:19:34 +02:00
:::
2017-10-10 11:15:24 +02:00
## strapi generate:service
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Create a new service
```bash
strapi generate:service < name >
options: [--api < name > |--plugin < name > ]
```
- **strapi generate:service & #60 ; name& #62 ; **< br />
Generates an empty service called ** & #60 ; name& #62 ; ** in the `./api/<name>/services` folder.
Example: `strapi generate:service category` will create the service at `./api/category/services/Category.js` .
- **strapi generate:service & #60 ; name& #62 ; --api & #60 ; api& #62 ; **< br />
Generates an empty service called ** & #60 ; name& #62 ; ** in the `./api/<api>/services` folder.
Example: `strapi generate:service category --api product` will create the service at `./api/product/services/Category.js` .
- **strapi generate:service & #60 ; name& #62 ; --plugin & #60 ; plugin& #62 ; **< br />
Generates an empty service called ** & #60 ; name& #62 ; ** in the `./plugins/<plugin>/services` folder.
2018-10-01 12:19:34 +02:00
::: note
2019-07-05 03:05:36 +02:00
The first letter of the filename will be uppercase.
2018-10-01 12:19:34 +02:00
:::
2017-10-10 11:15:24 +02:00
## strapi generate:policy
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Create a new policy
```bash
strapi generate:policy < name >
options: [--api < name > |--plugin < name > ]
```
- **strapi generate:policy & #60 ; name& #62 ; **< br />
Generates an empty policy called ** & #60 ; name& #62 ; ** in the `./config/policies` folder.
Example: `strapi generate:policy isAuthenticated` will create the policy at `./config/policies/isAuthenticated.js` .
- **strapi generate:policy & #60 ; name& #62 ; --api & #60 ; api& #62 ; **< br />
Generates an empty policy called ** & #60 ; name& #62 ; ** in the `./api/<api>/config/policies` folder. This policy will be scoped and only accessible by the ** & #60 ; api& #62 ; ** routes.
Example: `strapi generate:policy isAuthenticated --api product` will create the policy at `./api/product/config/policies/isAuthenticated.js` .
- **strapi generate:policy & #60 ; name& #62 ; --plugin & #60 ; plugin& #62 ; **< br />
Generates an empty policy called ** & #60 ; name& #62 ; ** in the `./plugins/<plugin>/config/policies` folder. This policy will be scoped and accessible only by the ** & #60 ; plugin& #62 ; ** routes.
## strapi generate:plugin
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Create a new plugin skeleton.
```bash
strapi generate:plugin < name >
```
- **strapi generate:plugin & #60 ; name& #62 ; **< br />
Generates an empty plugin called ** & #60 ; name& #62 ; ** in the `./plugins` folder.
Example: `strapi generate:plugin user` will create the plugin at `./plugins/user` .
2018-10-30 21:34:11 +03:00
Please refer to the [plugin development documentation ](../plugin-development/quick-start.md ) to know more.
2017-10-10 11:15:24 +02:00
2019-07-18 19:28:52 +02:00
---
2017-10-10 11:15:24 +02:00
## strapi install
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Install a plugin in the project.
```bash
strapi install < name >
options: [--dev]
```
- **strapi install & #60 ; name& #62 ; **< br />
Installs a plugin called ** & #60 ; name& #62 ; ** in the `./plugins` folder.
Example: `strapi install content-type-builder` will install the plugin at `./plugins/content-type-builder` .
- **strapi install & #60 ; name& #62 ; --dev**< br />
It will create a symlink from the local Strapi repository plugin folder called ** & #60 ; name& #62 ; ** in the `./plugins` folder.
Example: `strapi install content-type-builder --dev` will create a symlink from `/path/to/the/repository/packages/strapi-plugin-content-type-builder` to `./plugins/content-type-builder` .
2018-12-14 11:31:41 +01:00
::: note
Checkout the [CONTRIBUTING guide ](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md ) for more details about the local Strapi development workflow.
:::
2017-10-12 11:22:28 +02:00
2018-10-01 12:19:34 +02:00
::: warning
You have to restart the server to load the plugin into your project.
:::
2017-10-10 11:15:24 +02:00
2018-01-10 11:32:24 +01:00
Please refer to the [plugins documentation ](../plugin-development/quick-start.md ) to know more.
2017-10-10 11:15:24 +02:00
2019-07-18 19:28:52 +02:00
---
2017-10-10 11:15:24 +02:00
## strapi uninstall
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Uninstall a plugin from the project.
```bash
strapi uninstall < name >
```
- **strapi uninstall & #60 ; name& #62 ; **< br />
Uninstalls a plugin called ** & #60 ; name& #62 ; ** in the `./plugins` folder.
Example: `strapi uninstall content-type-builder` will remove the folder at `./plugins/content-type-builder` .
2018-01-10 11:32:24 +01:00
Please refer to the [plugins documentation ](../plugin-development/quick-start.md ) to know more.
2017-10-10 11:15:24 +02:00
2019-07-18 19:28:52 +02:00
---
2017-10-10 11:15:24 +02:00
## strapi version
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
Print the current globally installed Strapi version.
```bash
strapi version
```
2019-07-18 19:28:52 +02:00
---
2017-10-10 11:15:24 +02:00
## strapi help
2019-07-18 19:28:52 +02:00
2017-10-10 11:15:24 +02:00
List CLI commands.
```
strapi help
```