Skip to content

Commit f177362

Browse files
authored
update readme
1 parent b468ce0 commit f177362

1 file changed

Lines changed: 96 additions & 62 deletions

File tree

README.md

Lines changed: 96 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,167 @@
11
# Webrium Console
22

3-
<br>
43

5-
Webrium console provides a series of features to the developer and tries to make some tasks easier. For example, it can be used to create controller files or models, or view the list of databases or tables, etc.
64

7-
<br>
5+
The Webrium Console Commands include tools for generating files, calling methods, and managing databases. Below is a list of available commands and how to use them.
6+
87

9-
## Model operation
8+
## Generate a Model
109

11-
### Create a model
10+
The make:model command creates a new model file in the models directory. You can create either a simple model or a database-connected model.
1211

13-
The following example creates a blank model
12+
#### Usage
1413
```
15-
php webrium make:model User
14+
php webrium make:model <ModelName> [--table=<TableName>] [--force] [--no-plural]
1615
```
1716

18-
By using `--table` or `-t` according to the name of the model (for example, `User`), the name of the `users` table is automatically created and set in the model.
17+
- **ModelName** : The name of the model (e.g., User).
18+
- **--table|-t**: Specify the database table name (e.g., users). If omitted, the model name is converted to snake_case and pluralized (e.g., User becomes users).
19+
- **--force|-f**: Overwrite the model file if it already exists.
20+
- **--no-plural**: Prevent adding an "s" to the table name (e.g., User stays user instead of users).
1921

22+
#### Example
23+
```
24+
php webrium make:model User --table=users
25+
```
26+
Or instead of that
2027
```
21-
php webrium make:model User --table
22-
or
2328
php webrium make:model User -t
2429
```
2530

26-
You can also specify the desired table name
31+
This creates a User.php model file in the models directory, linked to the users table.
2732

28-
```
29-
php webrium make:model User --table=my_custom_table_name
30-
```
3133

3234
## Controller operation
3335

3436

35-
### Create a controller:
36-
In the example below, the `AuthController.php` file is created
37+
### Generate a Controller
38+
39+
The make:controller command creates a new controller file in the controllers directory.
3740

41+
#### Usage
3842
```
39-
php webrium make:controller Auth
43+
php webrium make:controller <ControllerName> [--force] [--namespace=<Namespace>]
4044
```
4145

42-
### Call methods
4346

44-
You can run your controller or model methods through the console and see its output
47+
ControllerName: The name of the controller (e.g., User). The suffix Controller is automatically added if not included.
4548

46-
Call Controller method
49+
- **--force|-f**: Overwrite the controller file if it already exists.
50+
- **--namespace**: Specify a custom namespace (default: App\Controllers).
51+
52+
#### Example
4753

4854
```
49-
php webrium call IndexController@getCurrentName
55+
php webrium make:controller User
5056
```
5157

52-
Call Model method
58+
This creates a UserController.php file in the controllers directory with the namespace App\Controllers.
5359

54-
```
55-
php webrium call -m User@getCount
5660

61+
62+
## Call a Controller or Model Method
63+
64+
The call command allows you to execute a method on a controller or model, passing optional parameters.
65+
66+
#### Usage
67+
68+
```
69+
php webrium call <Class@Method> [--params=<JSON>] [--model] [--namespace=<Namespace>]
5770
```
5871

59-
Parameters can be passed to the function in JSON format.
72+
- **Class@Method**: The class and method to call (e.g., UserController@getUsers or User@getDetails).
73+
- **--params|-p**: A JSON array of parameters (e.g., [1, "active"]). Defaults to an empty array.
74+
- **--model|-m**: Target a model instead of a controller.
75+
- **--namespace**: Specify a custom namespace (default: App\Controllers for controllers, App\Models for models).
76+
77+
78+
#### Example
6079

6180
```
62-
php webrium call -m SMS@RayeganSmsPatern -p '["parameter 1", "parametr 2"]'
81+
php webrium call UserController@getUsers --params='[1, "active"]'
6382
```
6483

84+
This calls the getUsers method on App\Controllers\UserController with the parameters [1, "active"].
85+
6586
<br>
6687

67-
## Database operations:
6888

69-
### Show Databases list
89+
## Manage Databases
7090

71-
The following command shows the list of all databases
91+
The `db` command provides tools to manage databases, including listing databases, viewing tables, creating databases, and deleting databases.
92+
93+
#### Usage
7294

7395
```
74-
php webrium db list
96+
php webrium db <action> [<DatabaseName>] [--use=<Database>] [--force]
7597
```
7698

77-
### Show Tables list
99+
- action: The action to perform:
100+
- list: List all databases.
101+
- tables: List tables in a database.
102+
- create: Create a new database.
103+
- drop: Delete a database.
78104

79-
It shows the list of current database tables.
105+
- **DatabaseName**: The name of the database (required for create and drop).
106+
- **--use|-u**: Specify a database for the tables action.
107+
- **--force|-f**: Skip confirmation when dropping a database.
80108

109+
110+
#### Examples
111+
112+
List all databases:
81113
```
82-
php webrium db tables
114+
php webrium db list
83115
```
84-
By using `--use`, you can view the list of other databases. But you must have already defined the databases in DB.php
116+
117+
List tables in a specific database:
85118
```
86-
php webrium db tables --use=second_db
119+
php webrium db tables --use=my_database
87120
```
88121

89-
### Create a new database
122+
Create a new database:
123+
90124
```
91-
php webrium db create prj_dbname
125+
php webrium db create my_database
92126
```
93127

94-
### Drop a database
95-
128+
Delete a database (with confirmation):
96129
```
97-
php webrium db drop dbname
130+
php webrium db drop my_database
98131
```
99132

133+
134+
100135
<br>
101136

102137

103-
## Table operation
138+
## Manage Tables
104139

105-
### Show columns and column information
140+
The table command allows you to manage database tables, including viewing column details and deleting tables.
141+
142+
#### Usage
106143
```
107-
php webrium table info users
108-
// or
109-
php webrium table columns users
144+
php webrium table <action> <TableName> [--use=<Database>] [--force]
110145
```
111-
In the example above, `users` is the name of the table we want to view its information.
112146

113-
### Drop a table
147+
- **action**: The action to perform:
148+
- **info** or `columns`: Display column details (name, type, null, key, default, extra).
149+
- **drop**: Delete the table.
150+
151+
- **TableName**: The name of the table.
152+
- **--use|-u**: Specify a database.
153+
- **--force|-f**: Skip confirmation when dropping a table.
114154

155+
#### Examples
156+
157+
View columns of a table:
115158
```
116-
php webrium table drop categorys
159+
php webrium table columns users
160+
```
161+
162+
Delete a table (with confirmation):
163+
```
164+
php webrium table drop users
117165
```
118166

119167
<br>
@@ -140,19 +188,5 @@ php webrium log file {log_file_name}
140188

141189
<br>
142190

143-
## Init Telegram bot
144-
There is also a feature for developers who want to develop Telegram bots
145-
We use [BotFire](github.com/botfire/botfire/) library for Telegram bot. And using the following commands, the initial configuration is created to implement the robot
146-
147-
```
148-
php webrium botfire:init your_bot_api_token
149-
```
150-
Replace your_bot_api_token with your bot token.
151-
152-
You can also enable debug mode as below
153191

154-
```
155-
php webrium botfire:init your_bot_api_token --debug=your_chat_id
156-
```
157-
By activating debug mode, when an error occurs, its text will be sent to your account instantly
158192

0 commit comments

Comments
 (0)