The best way to contribute to Monica is to use Homestead, which is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. The big advantage is that it runs on any Windows, Mac, or Linux system.
This is what is used to develop Monica and will provide a common base for everyone who wants to contribute to the project. Once Homestead is installed, you can pull the repository and start setup Monica.
composer install
in the folder the repository has been cloned.cp .env.example .env
- Update
.env
to your specific needs. - Run
php artisan key:generate
to generate an application key. This will setAPP_KEY
with the right value automatically. npm install
to install bower and gulp.bower install
to install front-end dependencies in thevendor
folder.- Create a database called
monica
. php artisan key:generate
to generate a random APP_KEYphp artisan migrate
to run all migrations.php artisan storage:link
to access the avatars.php artisan db:seed --class ActivityTypesTableSeeder
to populate the activity types.php artisan db:seed --class CountriesSeederTable
to populate the countries table.
Optional step: Seeding the database with fake data
This step is to populate the instance with fake data, so you can test with real data instead of lorem ipsum.
php artisan db:seed --class FakeContentTableSeeder
to load all seeds.
Note that this will create two accounts:
- First account is
[email protected]
with the passwordadmin
. This account contains a lot of fake data that will let you play with the product. - Second account is
[email protected]
with the passwordblank
. This account does not contain any data and shall be used to check all the blank states.
Monica uses the testing capabilities of Laravel to do unit. While all code will have to go through to Travis before being merged, tests can still be executed locally before pushing them. In fact, we encourage you strongly to do it first.
To setup the test environment, create a separate testing database locally:
- Create a database called
monica_test
Then you need to run the migrations specific to the testing database and runs the seeders to populate it:
php artisan migrate --database testing
php artisan db:seed --database testing
Once this is done, you have to use phpunit
command every time you want to run
the test suite.
Each time the schema of the database changes, you need to run again the migrations and the seeders by running the two commands above.
If you want to connect directly to Monica's MySQL instance read Connecting to MySQL inside of a Docker container.
We use Laravel Dusk to do functional testing. The most important is the unit tests - but functional testing is a very nice to have and we are happy to provide support for it. However, setting up the functional testing environment is really painful. Laravel Dusk should work fine if you use standard PHP, not in a VM (like Homestead), but I haven't tested it. If you do, please report and update this document.
The following setup instructions are for Homestead, which we recommend to contribute to Monica. Instructions come from this article.
- Setup Google Chrome Headless and XVFB in your VM
$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
$ sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
$ sudo apt-get update && sudo apt-get install -y google-chrome-stable
$ sudo apt-get install -y xvfb
- Start Chrome Driver in your VM. This instruction will open a port - let it open.
$ ./vendor/laravel/dusk/bin/chromedriver-linux --port=8888
- Add your project in
/etc/hosts
in your vagrant machine
127.0.0.1 your-project.app
- Open another SSH connection to the Vagrant Homestead machine and execute the following to run the xvfb server
$ Xvfb :0 -screen 0 1280x960x24 &
- On your first console, press CTLR+C and run the functional tests
php artisan dusk
You are done. It's horrible.
We use Bower to manage front-end dependencies. The first time you install the
project, you need to bower install
in the root of the project. When you want
to update the dependencies, run bower update
.
To install a new package, use bower install jquery -S
. The -S
option is to
update bower.json
to lock the specific version.
All the assets are stored in resources/vendor
.
CSS is written in SASS and therefore needs to be compiled before being used by
the application. To compile those front-end assets, use gulp
.
To monitor changes and compile assets on the fly, use gulp watch
.
At the current time, we are using Bootstrap 4 Alpha 2. Not everything though - we do use only what we need. I would have wanted to use something completely custom, but why reinvent the wheel? Anyway, make sure you don't update this dependency with Bower. If you do, make sure that everything is thoroughly tested as when Bootstrap changes version, a lot of changes are introduced.
Emails are an important part of Monica. Emails are still the most significant mean of communication and people like receiving them when they are relevant. That being said, you will need to test emails to make sure they contain what they should contain.
For development purposes, you have two choices to test emails:
- You can use Mailtrap. This is an amazing service that provides a free plan that is plenty enough to test all the emails that are sent.
- If you use Homestead to code on your local machine, you can use
mailhog that is built-in. To use it, you
first need to start mailhog (
sudo service mailhog restart
). Then, head up to http://localhost:8025 in your browser to load Mailhog's UI.
If you want to use mailhog, you need the following settings in your .env
file:
MAIL_DRIVER=smtp
MAIL_HOST=0.0.0.0
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
Reminders are generated and sent using an Artisan command
monica:sendnotifications
. This command is scheduled to be triggered every hour
in app/console/Kernel.php
.
Monica calculates every night (ie once per day) a set of metrics to help you understand how the instance is being used by users. That will also allow to measure growth over time.
Statistics are generated by the Artisan command monica:calculatestatistics
every night at midnight and this cron is defined in app/console/Kernel.php
.