Skip to content

Developing Bzion

alezakos edited this page Dec 10, 2015 · 8 revisions

Bzion is a complex project, based on a large number of different web technologies. As such, working with it as a developer can be painful without the right tools.

PHP

Bzion depends mostly (but not fully) on the Symfony 2 framework, has documentation compatible with phpDocumentor, as well as PHPUnit tests. We use Composer to make dependency management easier for both the developer, and the webmaster.

Getting ready to code

Installing dependencies

If you need to run tests, generate documentations or use the profiler, run:

php composer.phar install

That command should download and install the dependencies needed to develop with PHP.

Using a development environment

In app/config.yml, find the line:

    development: false

Convert the false into a force, so that some useful debug functions are enabled, such as the ability to log into BZFlag with your local IP address.

Setting up the cache

If you get errors about the cache folder not being writeable, you should make sure that the user of your web server has write permissions for the app/cache directory. A naive option is to give everyone full permissions:

chmod -R a+rwx app/cache

Adding sample data

To make testing easier, you can use our sampleData.php script to add sample data to the database:

php tests/sampleData.php

Running tests

First of all, you need to update your config with a database for testing (that can be the same as your regular database) -- just add the following to app/config.yml:

    testing:
        host: localhost
        database: bzion_testing
        username: bzion_tester
        password: password

And then set up the database structures:

composer migrate-database testing

After that, running tests on bzion is as simple as a phpunit or tests/runTests.sh command.

Reading the configuration parameters

app/console config:dump bzion # List all parameters in YAML format
app/console container:debug --parameters | grep bzion # List all parameters with their parameter names

Adding entries to the changelog

The changelog of the project can be found at the app/changelog.yml file, which is stored in a format readable both by humans and PHP. All new entries to the changelog are automatically displayed after a successful upgrade, allowing us to show everything that has changed to webmasters and possibly grab their attention concerning various issues.

The changelog file contains a list of changes sorted by type (features, bugfixes and miscellaneous notes) and date -- to add new entries, you can either edit it manually, or simply use the bzion:log command:

app/console bzion:log
# or
app/console bzion:log bug "Fixed segfault on invalid bread flavor"

To test your changes, just run:

app/console bzion:changes -d "this week"