This project is a platform + api to create alerts of severe events of meteorology. Its also creates the CAP (v1.2) files (Common Alert Protocol)
Create a new repository
1. $ git clone git@github.com:victorfleite/wwalerts-backend.git wwalert
Install Composer. For more.
2. $ curl -sS https://getcomposer.org/installer | php
3. $ sudo mv composer.phar /usr/local/bin/composer
4. $ sudo chown -fR yourUser:root /usr/local/bin/composer
5. $ sudo composer global require "fxp/composer-asset-plugin:^1.3.1"
Update Composer
6. $ cd yourFolderName
7. $ composer update
8. Create your local database
9. Set the database configuration on common/config/main-local.php
<?php
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'pgsql:host=localhost;dbname=databasename',
'username' => 'postgres',
'password' => 'postgres',
'charset' => 'utf8',
],
...
],
];
10. $ sudo chmod 777 /var/www/html/yourFolderName/backend/web/assets
Access you application on http://localhost/wwalert
Insert the username: victor.leite
Insert the password: mypassword
Login into the system (You have the administrator role) :-)
1. Token access required
curl -i -H "Accept:application/json" -H "Content-Type:application/json" "http://localhost/yourFolderName/service/api/www/index.php/oauth2/token" -XPOST \
-d '{"grant_type":"password","username":"victor.leite@gmail.com","password":"mypassword","client_id":"myclientId","client_secret":"mySecretPassword"}'
2. Token access required with scope
curl -i -H "Accept:application/json" -H "Content-Type:application/json" "http://localhost/yourFolderName/service/api/www/index.php/oauth2/token" -XPOST \
-d '{"grant_type":"password","username":"victor.leite@gmail.com","password":"mypassword","client_id":"myclientId","client_secret":"mySecretPassword","scope":"custom"}'
3 - User data required
curl -i -H "Accept:application/json" -H "Content-Type:application/json" "http://localhost/yourFolderName/service/api/www/index.php/v1/user/get-user?access_token={TOKEN_GERADO_NA_AUTENTICACAO}"
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
I decided to create this project to help people to accelerate the proccess to create application and services/api rest in the same project.
The MIT License
===============================
backend
assets/ contains application assets such as JavaScript and CSS
config/ contains backend configurations
controllers/ contains Web controller classes
models/ contains backend-specific model classes
runtime/ contains files generated during runtime
tests/ contains tests for backend application
views/ contains view files for the Web application
web/ contains the entry script and Web resources
widgets/ contains widgets for the Web application
common
config/ contains shared configurations
mail/ contains view files for e-mails
models/ contains model classes used in both backend and frontend
tests/ contains tests for common classes
console
config/ contains console configurations
controllers/ contains console controllers (commands)
migrations/ contains database migrations
models/ contains console-specific model classes
runtime/ contains files generated during runtime
service
api/common/ contains controllers or models commons for api application
api/components/ contains components that could be inherited by classes and controllers in each version (ex: versions/v1)
api/config/ contains shared configurations
api/versions/ versions of application
api/www/ initial folder for application
vendor/ contains dependent 3rd-party packages
===============================