Skip to content

Commit

Permalink
Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 29, 2018
1 parent bf9483c commit 2471c00
Show file tree
Hide file tree
Showing 89 changed files with 8,064 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .editorconfig
@@ -0,0 +1,26 @@
# EditorConfig is awesome: http://EditorConfig.org

# Top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Major extensions
[*.{js,vue,php,phpt,phtml,latte,md,neon}]
indent_style = tab
indent_size = 4

# YAML
[*.yml]
indent_style = space
indent_size = 2

# JSON
[*.json]
indent_style = tab
indent_size = 2
16 changes: 16 additions & 0 deletions .gitignore
@@ -0,0 +1,16 @@
# Nette
/app/config/config.local.neon

# Composer
/vendor

# NodeJS
/node_modules

# Assets
/www/dist

# Tests
/tests/*.log
/tests/tmp
/tests/coverage.html
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Projectte
Copyright (c) 2018 Planette

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 19 additions & 0 deletions Makefile
@@ -0,0 +1,19 @@
loc-postgres: loc-postgres-stop
docker run -it -d -p 5432:5432 --name nutella_postgres -e POSTGRES_PASSWORD=forest -e POSTGRES_USER=forest postgres:10

loc-postgres-stop:
docker stop nutella_postgres || true
docker rm nutella_postgres || true

loc-adminer: loc-adminer-stop
docker run -it -d -p 9999:80 --name nutella_adminer dockette/adminer:dg

loc-adminer-stop:
docker stop nutella_adminer || true
docker rm nutella_adminer || true

loc-api:
NETTE_DEBUG=1 NETTE_ENV=dev php -S 0.0.0.0:8000 www/index.php

loc-api-prod:
NETTE_ENV=prod php -S 0.0.0.0:8000 www/index.php
144 changes: 144 additions & 0 deletions README.md
@@ -0,0 +1,144 @@
# Forest Project

**Forest project** is an example project based on Nette Framework and many useful packages by [@f3l1x](https://github.com/f3l1x).

Why **forest**? Because we are building (fo)REST API.

## Goal

Main goal is to provide best prepared API starter-kit project for Nette-Apitte developers.

Focused on:

- `nette/*` packages
- Doctrine ORM via `nettrine/*`
- Symfony components via `contributte/*`
- codestyle checking via **CodeSniffer** and `ninjify/*`
- static analysing via **phpstan**
- unit / integration tests via **Nette Tester** and `ninjify/*`

## Install

1) At first, use composer to install this project.

```
composer create-project planette/forest-project
```

2) After that, you have to setup Postgres >= 10 database. You can start it manually or use docker image `postgres:10`.

```
docker run -it -p 5432:5432 -e POSTGRES_PASSWORD=forest -e POSTGRES_USER=forest postgres:10
```

Or use make task, `make loc-postgres`.

3) Custom configuration file is located at `app/config/config.local.neon`. Edit him if you want.

Default configuration should looks like:

```yaml
# Host Config
parameters:

# Database
database:
host: localhost
dbname: forest
user: forest
password: forest
```

4) Database is running, application is configure to connect to it. Create initial data.

Run `NETTE_DEBUG=1 bin/console migrations:migrate` to create tables.
Run `NETTE_DEBUG=1 bin/console doctrine:fixtures:load --append` to create first user(s).

5) Start your devstack or use PHP local development server.

PHP server is started by `php -S localhost:8000 -t www` or use prepared make task `make loc-web`.

6) Open http://localhost and enjoy it!

Take a look at:
- http://localhost:8000/api/public/v1/openapi/meta (Swagger format)
- http://localhost:8000/api/v1/users
- http://localhost:8000/api/v1/users?access_token=admin
- http://localhost:8000/api/v1/users/1?access_token=admin
- http://localhost:8000/api/v1/users/999?access_token=admin
- http://localhost:8000/api/v1/users/email?email=admin@admin.cz&access_token=admin

## Features

Here is a list of all features you can find in this project.

- :package: Packages
- Nette 2.4
- Contributte
- Nettrine
- Apitte
- :deciduous_tree: Structure
- `app`
- `config` - configuration files
- `env` - prod/dev/test environments
- `app` - application configs
- `ext` - extensions configs
- `config.local.neon` - local runtime config
- `config.local.neon.dist` - template for local config
- `domain` - business logic and domain specific classes
- `model` - application backbone
- `module` - API module
- `resources` - static content for mails and others
- `bootstrap.php` - Nette entrypoint
- `bin` - console entrypoint (`bin/console`)
- `db` - database files
- `fixtures` - PHP fixtures
- `migrations` - migrations files
- `docs` - documentation
- `log` - runtime and error logs
- `temp` - temp files and cache
- `tests` - test engine and unit/integration tests
- `vendor` - composer's folder
- `www` - public content
- :exclamation: Tracy
- Cool error 500 page

### Composer packages

Take a detail look :eyes: at each single package.

- [contributte/bootstrap](https://contributte.org/packages/contributte/bootstrap.html)
- [contributte/di](https://contributte.org/packages/contributte/di.html)
- [contributte/http](https://contributte.org/packages/contributte/http.html)
- [contributte/security](https://contributte.org/packages/contributte/security.html)
- [contributte/utils](https://contributte.org/packages/contributte/utils.html)
- [contributte/tracy](https://contributte.org/packages/contributte/tracy.html)
- [contributte/console](https://contributte.org/packages/contributte/console.html)
- [contributte/neonizer](https://contributte.org/packages/contributte/neonizer.html)
- [contributte/monolog](https://contributte.org/packages/contributte/monolog.html)

**Apitte**

- [apitte/core](https://contributte.org/packages/apitte/core.html)
- [apitte/debug](https://contributte.org/packages/apitte/debug.html)
- [apitte/middlewares](https://contributte.org/packages/apitte/middlewares.html)
- [apitte/openapi](https://contributte.org/packages/apitte/openapi.html)

**Nettrine**

- [nettrine/orm](https://contributte.org/packages/nettrine/orm.html)
- [nettrine/dbal](https://contributte.org/packages/nettrine/dbal.html)
- [nettrine/migrations](https://contributte.org/packages/nettrine/migrations.html)
- [nettrine/fixtures](https://contributte.org/packages/nettrine/fixtures.html)
- [nettrine/extensions](https://contributte.org/packages/nettrine/extensions.html)

**Nette**

- [nette/finder](https://github.com/nette/finder)
- [nette/robot-loader](https://github.com/nette/robot-loader)

## Demo

![](docs/assets/screenshot1.png)
![](docs/assets/screenshot2.png)
![](docs/assets/screenshot3.png)
2 changes: 2 additions & 0 deletions app/.htaccess
@@ -0,0 +1,2 @@
Order Allow,Deny
Deny from all
43 changes: 43 additions & 0 deletions app/bootstrap.php
@@ -0,0 +1,43 @@
<?php declare(strict_types = 1);

use Contributte\Bootstrap\ExtraConfigurator;
use Nette\DI\Compiler;
use Tracy\Debugger;

require __DIR__ . '/../vendor/autoload.php';

$configurator = new ExtraConfigurator();
$configurator->setTempDirectory(__DIR__ . '/../temp');

// Disable default extensions
$configurator->defaultExtensions['security'] = false;

$configurator->onCompile[] = function (ExtraConfigurator $configurator, Compiler $compiler): void {
// Add env variables to config structure
$compiler->addConfig(['parameters' => $configurator->getEnvironmentParameters()]);
};

// According to NETTE_DEBUG env
$configurator->setEnvDebugMode();

// Enable tracy and configure it
$configurator->enableTracy(__DIR__ . '/../log');
Debugger::$errorTemplate = __DIR__ . '/resources/tracy/500.txt';

// Provide some parameters
$configurator->addParameters([
'rootDir' => realpath(__DIR__ . '/..'),
'appDir' => __DIR__,
'wwwDir' => realpath(__DIR__ . '/../www'),
]);

// Load development or production config
if (getenv('NETTE_ENV', true) === 'dev') {
$configurator->addConfig(__DIR__ . '/config/env/dev.neon');
} else {
$configurator->addConfig(__DIR__ . '/config/env/prod.neon');
}

$configurator->addConfig(__DIR__ . '/config/config.local.neon');

return $configurator->createContainer();
13 changes: 13 additions & 0 deletions app/config/app/parameters.neon
@@ -0,0 +1,13 @@
# Parameters
#
parameters:

# System
system:
error:
email: nutella@localhost
presenter: Front:Error

# Database
database:
driver: pdo_pgsql
6 changes: 6 additions & 0 deletions app/config/app/services.neon
@@ -0,0 +1,6 @@
# Services
#
services:
# Domain =================
- App\Domain\Api\Facade\UsersFacade
- App\Domain\User\CreateUserFacade
9 changes: 9 additions & 0 deletions app/config/config.local.neon.dist
@@ -0,0 +1,9 @@
# Host Config
parameters:

# Database
database:
host: localhost
dbname: forest
user: forest
password: forest
23 changes: 23 additions & 0 deletions app/config/env/base.neon
@@ -0,0 +1,23 @@
# Core Config
includes:
# Application
- ../app/parameters.neon
- ../app/services.neon

# Extensions
- ../ext/apitte.neon
- ../ext/contributte.neon
- ../ext/nettrine.neon

php:
date.timezone: Europe/Prague
output_buffering: 4096

# Nette section
di:
debugger: false

tracy:
email: %system.error.email%
logSeverity: E_ALL
strictMode: yes
8 changes: 8 additions & 0 deletions app/config/env/dev.neon
@@ -0,0 +1,8 @@
# Production Config
includes:
- base.neon


# Nettrine ===================
orm.cache:
defaultDriver: filesystem
3 changes: 3 additions & 0 deletions app/config/env/prod.neon
@@ -0,0 +1,3 @@
# Production Config
includes:
- base.neon
25 changes: 25 additions & 0 deletions app/config/env/test.neon
@@ -0,0 +1,25 @@
# Test Config
includes:
- base.neon


# Nettrine ===================
orm:
configuration:
autoGenerateProxyClasses: ::constant(Doctrine\Common\Proxy\AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS)

orm.cache:
defaultDriver: array

orm.annotations:
cache: Doctrine\Common\Cache\ArrayCache


# Parameters =================
parameters:
database:
driver: pdo_sqlite
host: test
dbname: test
user: test
password: test

0 comments on commit 2471c00

Please sign in to comment.