Skip to content

Commit 2c30012

Browse files
committed
updated installation, howto
Signed-off-by: bidi <bidi@apidemia.com>
1 parent ef9c7b2 commit 2c30012

11 files changed

Lines changed: 217 additions & 69 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Fixtures
2+
3+
> Fixtures are used to seed the database with initial values and should only be executed ONCE each, after migrating the database.
4+
5+
Seeding the database is done with the help of our custom package `dotkernel/dot-data-fixtures` built on top of `doctrine/data-fixtures`.
6+
See below on how to use our CLI command for listing and executing Doctrine data fixtures.
7+
8+
## Working with fixtures
9+
10+
You can find an example of a fixtures class in `data/doctrine/fixtures/AdminLoader.php`.
11+
12+
To list all the available fixtures by order of execution run:
13+
14+
```shell
15+
php bin/doctrine fixtures:list
16+
```
17+
18+
To execute all fixtures run:
19+
20+
```shell
21+
php bin/doctrine fixtures:execute
22+
```
23+
24+
To execute a specific fixture, use its class name, like in this example:
25+
26+
```shell
27+
php bin/doctrine fixtures:execute --class=AdminLoader
28+
```
29+
30+
Fixtures can and should be ordered to ensure database consistency.
31+
More on ordering fixtures can be found here :
32+
https://www.doctrine-project.org/projects/doctrine-data-fixtures/en/latest/how-to/fixture-ordering.html#fixture-ordering
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Creating migrations
2+
3+
Migrations are used to create and/or edit the database structure.
4+
To generate a new migration file, use this command:
5+
6+
```shell
7+
php vendor/bin/doctrine-migrations migrations:generate
8+
```
9+
10+
It creates a PHP file like this one `/data/doctrine/migrations/Version20240627134952.php` that can then be edited in the IDE.
11+
You can add new queries in:
12+
13+
- `public function up` - these are executed when the migration is run.
14+
- `public function down` - these are optional queries that undo the above changes.
15+
16+
## Example
17+
18+
This example creates a new column named `test`.
19+
Add this in `public function up`:
20+
21+
```shell
22+
$this->addSql('ALTER TABLE admin ADD test VARCHAR(255) NOT NULL');
23+
```
24+
25+
And its opposite in `public function down`:
26+
27+
```shell
28+
$this->addSql('ALTER TABLE admin DROP test');
29+
```

docs/book/v5/installation/composer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Composer Installation of Packages
22

3-
Composer is required to install Dotkernel `admin`. You can install Composer from the [official site](https://getcomposer.org/).
3+
Composer is required to install Dotkernel Admin. You can install Composer from the [official site](https://getcomposer.org/).
44

55
> First make sure that you have navigated your command prompt to the folder where you copied the files in the previous step.
66

docs/book/v5/installation/configuration-files.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,30 @@
33
## Prepare config files
44

55
* duplicate `config/autoload/local.php.dist` as `config/autoload/local.php`
6-
76
* duplicate `config/autoload/mail.local.php.dist` as `config/autoload/mail.local.php`
87

9-
### Note
8+
> If you intend to send emails from your Frontend, make sure to fill in SMTP connection params.
9+
> This will be covered in the next section.
1010
11-
> if your Admin will send emails, make sure to fill in SMTP connection params
11+
> **optional**: in order to run/create tests, duplicate `config/autoload/local.test.php.dist` as `config/autoload/local.test.php`
12+
> this creates a new in-memory database that your tests will run on.
1213
13-
* **optional**: in order to run/create tests, duplicate `config/autoload/local.test.php.dist` as `config/autoload/local.test.php`
14+
## Mail
1415

15-
### Note
16+
If you want your application to send mail, add valid credentials to the following keys in `config/autoload/mail.local.php`
1617

17-
> this creates a new in-memory database that your tests will run on.
18+
Under `message_options` key:
19+
20+
- `from` - email address that will send emails (required)
21+
- `from_name` - organization name for signing sent emails (optional)
22+
23+
Under `smtp_options` key:
24+
25+
- `host` - hostname or IP address of the mail server (required)
26+
- `connection_config` - add the `username` and `password` keys (required)
27+
28+
In `config/autoload/local.php` edit the key `contact` => `message_receivers` => `to` with *string* values for emails that should receive contact messages.
29+
30+
> **Please add at least 1 email address in order for contact message to reach someone**
31+
32+
Also feel free to add as many CCs as you require under the `contact` => `message_receivers` => `cc` key.

docs/book/v5/installation/doctrine-orm.md

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,85 @@
11
# Doctrine ORM
22

3+
This step saves the database connection credentials in an Admin configuration file.
4+
We do not cover the creation steps of the database itself.
5+
36
## Setup database
47

5-
Make sure you fill out the database credentials in `config/autoload/local.php` under `$databases['default']`.
8+
Create a new MySQL database and set its collation to `utf8mb4_general_ci`.
69

7-
Create a new MySQL database - set collation to `utf8mb4_general_ci`
10+
Make sure you fill out the database credentials in `config/autoload/local.php` under `$databases['default']`.
11+
Below is the item you need to focus on.
12+
13+
> `my_database`, `my_user`, `my_password` are provided only as an example.
14+
15+
```php
16+
$databases = [
17+
'default' => [
18+
'host' => 'localhost',
19+
'dbname' => 'my_database',
20+
'user' => 'my_user',
21+
'password' => 'my_password',
22+
'port' => 3306,
23+
'driver' => 'pdo_mysql',
24+
'charset' => 'utf8mb4',
25+
'collate' => 'utf8mb4_general_ci',
26+
],
27+
// you can add more database connections into this array
28+
];
29+
```
830

931
## Running migrations
1032

1133
Run the database migrations by using the following command:
1234

1335
```shell
14-
php bin/doctrine-migrations migrate
36+
php vendor/bin/doctrine-migrations migrate
1537
```
1638

17-
This command will prompt you to confirm that you want to run it.
39+
Note: If you have already run the migrations, you may get this message.
40+
You should double-check to make sure the new migrations are ok to run.
1841

19-
> WARNING! You are about to execute a migration in database "..." that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
42+
```shell
43+
WARNING! You have x previously executed migrations in the database that are not registered migrations.
44+
{migration list}
45+
Are you sure you wish to continue? (y/n)
46+
```
2047

21-
Hit `Enter` to confirm the operation.
48+
When using an empty database, you will get this confirmation message instead.
2249

23-
## Executing fixtures
50+
```shell
51+
WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue? (y/n)
52+
```
2453

25-
**Fixtures are used to seed the database with initial values and should be executed after migrating the database.**
54+
Again, submit `y` to run all the migrations in chronological order.
55+
Each migration will be logged in the `migrations` table to prevent running the same migration more than once, which is often not desirable.
2656

27-
To list all the fixtures, run:
57+
If everything ran correctly, you will get this confirmation.
2858

2959
```shell
30-
php bin/doctrine fixtures:list
60+
[OK] Successfully migrated to version: Admin\Migrations\Version20240627134952
3161
```
3262

33-
This will output all the fixtures in the order of execution.
63+
> The migration name `Version20240627134952` may differ in future Admin updates.
3464
35-
To execute all fixtures, run:
65+
## Fixtures
66+
67+
Run this command to populate the admin tables with the default values:
3668

3769
```shell
3870
php bin/doctrine fixtures:execute
3971
```
4072

41-
To execute a specific fixture, run:
73+
You should see our galloping horse in the command line.
4274

4375
```shell
44-
php bin/doctrine fixtures:execute --class=FixtureClassName
76+
Executing Admin\Fixtures\AdminRoleLoader
77+
Executing Admin\Fixtures\AdminLoader
78+
Fixtures have been loaded.
79+
.''
80+
._.-.___.' (`\
81+
//( ( `'
82+
'/ )\ ).__. )
83+
' <' `\ ._/'\
84+
` \ \
4585
```
46-
47-
More details on how fixtures work can be found here: https://github.com/dotkernel/dot-data-fixtures#creating-fixtures

docs/book/v5/installation/getting-started.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,25 @@
55
> If you are using Windows as OS on your machine, you can use WSL2 as development environment.
66
> Read more here: [PHP-Mariadb-on-WLS2](https://www.dotkernel.com/php-development/almalinux-9-in-wsl2-install-php-apache-mariadb-composer-phpmyadmin/)
77
8-
Using your terminal, navigate inside the directory you want to download the project files into. Make sure that the
9-
directory is empty before proceeding to the download process. Once there, run the following command:
8+
Using your terminal, navigate inside the directory you want to download the project files into.
9+
Make sure that the directory is empty before proceeding to the download process.
10+
Once there, run the following command:
1011

1112
```shell
1213
git clone https://github.com/dotkernel/admin.git .
1314
```
15+
16+
If everything ran correctly, you can expect to see an output like this, though the numbers may differ.
17+
18+
```shell
19+
Cloning into '.'...
20+
remote: Enumerating objects: 6538, done.
21+
remote: Counting objects: 100% (1652/1652), done.
22+
remote: Compressing objects: 100% (785/785), done.
23+
remote: Total 6538 (delta 804), reused 1417 (delta 748), pack-reused 4886 (from 1)
24+
Receiving objects: 100% (6538/6538), 11.84 MiB | 16.52 MiB/s, done.
25+
Resolving deltas: 100% (3359/3359), done.
26+
```
27+
28+
You can already open the project in your preferred IDE to double-check the files were copied correctly.
29+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Introduction
2+
3+
In this tutorial, we will install Dotkernel Admin from scratch.
4+
We will focus on these tasks:
5+
6+
- Highlight 3rd party tools required for the installation.
7+
- Provide all the relevant commands with expected responses.
8+
- Configure the development environment.
9+
- Run the project.
10+
11+
By the end of this tutorial you will have a fully-functional Dotkernel Admin on your selected environment and can begin coding.
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
# Manage GeoLite2 database
1+
# Manage the GeoLite2 databases
22

3-
You can download/update a specific GeoLite2 database, by running the following command:
3+
You can download/update a specific GeoLite2 database, by running the following command where `{DATABASE}` can be `asn`, `city`, `country`:
44

5-
php bin/cli.php geoip:synchronize -d {DATABASE}
6-
7-
Where _{DATABASE}_ takes one of the following values: `asn`, `city`, `country`.
5+
```shell
6+
php bin/cli.php geoip:synchronize -d {DATABASE}
7+
```
88

99
You can download/update all GeoLite2 databases at once, by running the following command:
1010

11-
php bin/cli.php geoip:synchronize
11+
```shell
12+
php bin/cli.php geoip:synchronize
13+
```
14+
15+
The output should be similar to the below, displaying per row: `database identifier`: `previous build datetime` -> `current build datetime`.
1216

13-
The output should be similar to the below, displaying per
14-
row: `database identifier`: `previous build datetime` -> `current build datetime`.
17+
```shell
18+
asn: n/a -> 2024-11-01 02:29:44
19+
city: n/a -> 2024-11-01 02:29:31
20+
country: n/a -> 2024-11-01 02:25:09
21+
```
1522

16-
> asn: n/a -> 2021-07-01 02:09:34
17-
>
18-
> city: n/a -> 2021-07-01 02:09:20
19-
>
20-
> country: n/a -> 2021-07-01 02:05:12
23+
> `n/a` will be replaced by the older version of the GeoLite2 databases when you run the command again.
2124
2225
Get help for this command by running:
2326

24-
php bin/cli.php help geoip:synchronize
27+
```shell
28+
php bin/cli.php help geoip:synchronize
29+
```
2530

26-
**Tip**: If you setup the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output
27-
data only if an error has occurred.
31+
**Tip**: If you set up the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output data only if an error has occurred.
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
# Testing (Running)
1+
# Running the application
22

3-
Note: **Do not enable dev mode in production**
3+
> **Do not enable dev mode in production**
44
5-
- Run the following command in your project's directory to start PHPs built-in server:
5+
We recommend running your applications in WSL:
66

7-
php -S 0.0.0.0:8080 -t public
7+
- Make sure you have [WSL](https://github.com/dotkernel/development/blob/main/wsl/README.md) installed on your system.
8+
- Currently we provide a distro implementations for [AlmaLinux9](https://github.com/dotkernel/development/blob/main/wsl/os/almalinux9/README.md).
9+
- Install the application in a virtualhost as recommended by the chosen distro.
10+
- Set `$baseUrl` in **config/autoload/local.php** to the address of the virtualhost.
11+
- Run the application by opening the virtualhost address in your browser.
812

9-
> Running command `composer serve` will do the exact same, but the above is faster.
10-
11-
`0.0.0.0` means that the server is open to all incoming connections
12-
`127.0.0.1` means that the server can only be accessed locally (localhost only)
13-
`8080` the port on which the server is started (the listening port for the server)
14-
15-
**NOTE:**
16-
If you are still getting exceptions or errors regarding some missing services, try running the following command
17-
18-
php bin/clear-config-cache.php
13+
You should see the `Dotkernel admin` login page.
1914

20-
> If `config-cache.php` is present that config will be loaded regardless of the `ConfigAggregator::ENABLE_CACHE`
21-
> in `config/autoload/mezzio.global.php`
15+
> If you are getting exceptions or errors regarding some missing services, try running the following command:
2216
23-
- Open a web browser and visit `http://localhost:8080/`
17+
```shell
18+
sudo php bin/clear-config-cache.php
19+
```
2420

25-
You should see the `Dotkernel admin` login page.
21+
> If `config-cache.php` is present that config will be loaded regardless of the `ConfigAggregator::ENABLE_CACHE` in `config/autoload/mezzio.global.php`
2622
27-
If you ran the migrations you will have an admin user in the database with the following credentials:
23+
If you ran the fixtures you will have an admin user in the database with the following credentials:
2824

2925
- **User**: `admin`
3026
- **Password**: `dotadmin`
3127

32-
**NOTE:**
28+
> **Production only**: Make sure you modify the default admin credentials.
29+
30+
> **Development only**: `session.cookie_secure` does not work locally so make sure you modify your `local.php`, as per the following:
3331
34-
- **Production only**: Make sure you modify the default admin credentials.
35-
- **Development only**: `session.cookie_secure` does not work locally so make sure you modify your `local.php`, as per the following:
32+
```php
33+
# other code
3634

37-
return [
38-
'session_config' => [
39-
'cookie_secure' => false,
40-
]
41-
];
35+
return [
36+
# other configurations...
37+
'session_config' => [
38+
'cookie_secure' => false,
39+
],
40+
];
41+
```
4242

4343
Do not change this in `local.php.dist` as well because this value should remain `true` on production.

docs/book/v5/introduction/file-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It is considered good practice to standardize the file structure of projects.
66

77
When using Dotkernel Admin the following structure is installed by default:
88

9-
![Dotkernel Admin File Structure!](https://docs.dotkernel.org/img/Admin/file-structure-dk-Admin.png)
9+
![Dotkernel Admin File Structure!](https://docs.dotkernel.org/img/admin/file-structure-dk-admin.jpg)
1010

1111
## Main directories
1212

0 commit comments

Comments
 (0)