mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
database config
This commit is contained in:
parent
8fbd546205
commit
f3201cdf54
54
README.md
54
README.md
@ -37,7 +37,61 @@ composer check-platform-reqs
|
|||||||
### install the vendors
|
### install the vendors
|
||||||
```bash
|
```bash
|
||||||
composer install
|
composer install
|
||||||
|
```#Funky Framadate API
|
||||||
|
Experimental REST backend in symfony 4 for Funky framadate frontend.
|
||||||
|
https://framagit.org/framasoft/framadate/funky-framadate-front
|
||||||
|
|
||||||
|
Follow this guide to setup.
|
||||||
|
* run `composer install`
|
||||||
|
configure env by creating local env file
|
||||||
|
`cp .env .env.local` and edit the file variables to give access to database.
|
||||||
|
|
||||||
|
## TODO:
|
||||||
|
* coordinate properties and paths to be more restful.
|
||||||
|
|
||||||
|
return stack of votes when we want to get the configuration of one poll (see [doc/examples.md](doc/examples.md))
|
||||||
|
|
||||||
|
***
|
||||||
|
### Requirements
|
||||||
|
You MUST have php version 7+ and [Composer](https://getcomposer.org/download/), and a database like Mysql, or postgresql, or mongodb, or any database that Doctrine can handle.
|
||||||
|
Setup access to database by creating a .env.local file, and fill the database user and password data.
|
||||||
|
you can check that the database connection works with the command:
|
||||||
|
```bash
|
||||||
|
php bin/console doctrine:schema:validate
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
# Development
|
||||||
|
install dependencies with Composer
|
||||||
|
|
||||||
|
|
||||||
|
there are examples of request to make it all work in the [doc/examples.md](doc/examples.md).
|
||||||
|
|
||||||
|
### Check prerequisites
|
||||||
|
```bash
|
||||||
|
composer check-platform-reqs
|
||||||
|
```
|
||||||
|
|
||||||
|
### install the vendors
|
||||||
|
```bash
|
||||||
|
composer install
|
||||||
|
```
|
||||||
|
### configure database access in .env.local file
|
||||||
|
This project can use any database system, we provide config for mysql.
|
||||||
|
|
||||||
|
If you need to setup mysql, a database and a user, read the [database_creation](doc/database_creation.md) doc. Before customizing your local environment config.
|
||||||
|
the .env.local file will not be versionned by git, so no risk to set the mysql credentials in here as long as file access are well done.
|
||||||
|
|
||||||
|
You can copy the model env file and customize it last line to access mysql.
|
||||||
|
```bash
|
||||||
|
cp doc/env-example .env.local
|
||||||
|
```
|
||||||
|
look for the line like this
|
||||||
|
> DATABASE_URL=mysql://framadate-admin:framadate-admin-password@127.0.0.1:5432/framadate-api
|
||||||
|
|
||||||
|
and change its values for `framadate-admin` , `framadate-admin-password`, `framadate-api`.
|
||||||
|
|
||||||
### initiate the database with fixtures
|
### initiate the database with fixtures
|
||||||
```bash
|
```bash
|
||||||
php bin/console doctrine:schema:drop --force
|
php bin/console doctrine:schema:drop --force
|
||||||
|
1078
composer.lock
generated
1078
composer.lock
generated
File diff suppressed because it is too large
Load Diff
13
doc/database_creation.md
Normal file
13
doc/database_creation.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#Database setup
|
||||||
|
|
||||||
|
In the mysql prompt, to create a new user and a dedicated database, run this:
|
||||||
|
```
|
||||||
|
CREATE DATABASE IF NOT EXISTS framadate_api;
|
||||||
|
CREATE USER 'framadate-admin'@'localhost' IDENTIFIED BY 'framadate-admin-password';
|
||||||
|
GRANT ALL PRIVILEGES ON framadate_api.* TO 'framadate-admin'@'localhost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
SHOW GRANTS FOR 'framadate-admin'@'localhost';
|
||||||
|
SHOW DATABASES;
|
||||||
|
```
|
||||||
|
|
||||||
|
now you have your config ready to host Framadate API.
|
53
doc/env-example
Executable file
53
doc/env-example
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
# In all environments, the following files are loaded if they exist,
|
||||||
|
# the latter taking precedence over the former:
|
||||||
|
#
|
||||||
|
# * .env contains default values for the environment variables needed by the app
|
||||||
|
# * .env.local uncommitted file with local overrides
|
||||||
|
# * .env.$APP_ENV committed environment-specific defaults
|
||||||
|
# * .env.$APP_ENV.local uncommitted environment-specific overrides
|
||||||
|
#
|
||||||
|
# Real environment variables win over .env files.
|
||||||
|
#
|
||||||
|
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
|
||||||
|
#
|
||||||
|
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
|
||||||
|
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
|
||||||
|
|
||||||
|
###> symfony/framework-bundle ###
|
||||||
|
APP_ENV=dev
|
||||||
|
ADMIN_TOKEN=CHANGE_THIS_STRING_HERE
|
||||||
|
APP_SECRET=CHANGE_THIS_STRING_THERE
|
||||||
|
# Base website url, should contain https:// and having no trailing slash. example: BASE_URL=https://framadate.org
|
||||||
|
BASE_URL=https://localhost
|
||||||
|
WEBSITE_NAME=Framadate_2
|
||||||
|
WEBSITE_LOGO=logo.svg
|
||||||
|
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
|
||||||
|
#TRUSTED_HOSTS='^localhost|example\.com$'
|
||||||
|
###< symfony/framework-bundle ###
|
||||||
|
|
||||||
|
###> doctrine/doctrine-bundle ###
|
||||||
|
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
|
||||||
|
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
|
||||||
|
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11"
|
||||||
|
# IMPORTANT: You MUST also configure your db driver and server_version in config/packages/doctrine.yaml
|
||||||
|
DATABASE_URL=mysql://framadate-admin:framadate-admin-password@127.0.0.1:5432/framadate-api
|
||||||
|
###< doctrine/doctrine-bundle ###
|
||||||
|
|
||||||
|
###> nelmio/cors-bundle ###
|
||||||
|
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
|
||||||
|
###< nelmio/cors-bundle ###
|
||||||
|
|
||||||
|
###> symfony/swiftmailer-bundle ###
|
||||||
|
# For Gmail as a transport, use: "gmail://username:password@localhost"
|
||||||
|
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
|
||||||
|
# Delivery is disabled by default via "null://localhost"
|
||||||
|
MAILER_URL=sendmail://YOUR_WEBSITE
|
||||||
|
# set the support email who will answer users in case of emergency
|
||||||
|
SUPPORT_EMAIL=YOUR_EMAIL
|
||||||
|
###< symfony/swiftmailer-bundle ###
|
||||||
|
|
||||||
|
###> symfony/mailer ###
|
||||||
|
MAILER_DSN=smtp://localhost
|
||||||
|
###< symfony/mailer ###
|
||||||
|
|
||||||
|
DATABASE_URL=mysql://framadate-admin:framadate-admin-password@127.0.0.1:5432/framadate-api
|
@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"composer/package-versions-deprecated": {
|
||||||
|
"version": "1.11.99.1"
|
||||||
|
},
|
||||||
"doctrine/annotations": {
|
"doctrine/annotations": {
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
@ -300,6 +303,9 @@
|
|||||||
"symfony/dependency-injection": {
|
"symfony/dependency-injection": {
|
||||||
"version": "v4.3.5"
|
"version": "v4.3.5"
|
||||||
},
|
},
|
||||||
|
"symfony/deprecation-contracts": {
|
||||||
|
"version": "v2.2.0"
|
||||||
|
},
|
||||||
"symfony/doctrine-bridge": {
|
"symfony/doctrine-bridge": {
|
||||||
"version": "v4.3.5"
|
"version": "v4.3.5"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user