Install dependencies :
composer install
Create database for the project by importing eloquent_example.sql and update the config/config.php:
<?php
return [
'settings' => [
'displayErrorDetails' => true,
'db' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'eloquent_example',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'unix_socket' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock',
]
],
];
Run the project :
php -S localhost:8088
There are multiple ways how to setup logging. The application now supports rotating file logging and slack logging.
Logging levels:
- DEBUG (100)
- INFO (200)
- NOTICE(250)
- WARNING (300)
- ERROR (400)
- CRITICAL (500)
- ALERT(550)
- EMERGENCY (600)
Rotating file:
...
'log' => [
'file' => [
'level' => 100,
'file' => 'path/to/file',
]
],
...
GraphQL debug modes:
- INCLUDE_DEBUG_MESSAGE (1)
- INCLUDE_TRACE(2)
- RETHROW_INTERNAL_EXCEPTIONS (4)
...
'graphql' => [
'debug' => INCLUDE_DEBUG_MESSAGE | INCLUDE_TRACE,
],
...
...
'graphql' => [
'maxDepth' => 10,
],
...
...
'graphql' => [
'introspection' => true,
],
...
query {
authors {
edges {
node {
id
_id
firstName
lastName
}
}
}
}
query {
authors(firstName: "John") {
edges {
node {
id
_id
firstName
lastName
}
}
}
}
query {
authors(orderBy:[
{
field:FIRST_NAME
direction:ASC
}
{
field:LAST_NAME
direction:ASC
}
]) {
edges {
cursor
node {
_id
firstName
lastName
}
}
}
}
mutation {
createAuthor(input:{firstName:"Fredrick", lastName:"Brooks"}) {
id
_id
firstName
lastName
}
}
Run PHPUnit:
./vendor/bin/phpunit
# or
./vendor/bin/phpunit --bootstrap ./vendor/autoload.php --testdox tests
Use PHP Stan to analyse php files for basic errors:
./vendor/bin/phpstan analyse src