Firebird Documentation IndexFirebird 3.0 Developer's GuideDeveloping Web Applications with PHP and Firebird → Creating a Project
Firebird Home Firebird Home Prev: Installing LaravelFirebird Documentation IndexUp: Developing Web Applications with PHP and FirebirdNext: Creating Models

Creating a Project

Table of Contents

Our Project's Structure
Configuration

If the installation is successful, we can carry on with creating the project framework. Enter:

  laravel new fbexample
      

Wait until it finishes creating the project framework. A description of the directory structure can be found in the Laravel documentation.

Our Project's Structure

These are the directories we are most interested in:

  • app—the main directory of our application. Models will be located in the root directory. The Http subdirectory contains everything that is related to working with the browser. The Http/Controllers subdirectory contains our controllers.

  • config—the directory with configuration files. You will discover more details about the configuration process later.

  • public—the root directory of the web application (DocumentRoot). It contains static files: css, js, images, etc.

  • resources—contains views, localization files and, if any, LESS files, SASS and js applications on such frameworks as ReactJS, AngularJS or Ember that are later put together into the public folder with an external tool.

  • The root directory of our application contains the composer.json file that describes the packages our application will need besides those that are already present in Laravel.

    We will need two such packages: zofe/rapyd-laravel for building a quick interface with grids and edit dialog boxes, and sim1984/laravel-firebird, an extension for working with Firebird databases.

The sim1984/laravel-firebird package is the author's fork of the jacquestvanzuydam/laravel-firebird package. Its installation is a bit different. A description of how the package differs from the original is available in the article Package for working with the Firebird DBMS in Laravel if you can read Russian. An English-language description of the packages and the changes from the original can be found in the readme.md document at this URL: https://github.com/sim1984/laravel-firebird.

Caution

Remember to set the minimum-stability parameter to 'dev' because the package is not stable enough to publish at https://packagist.org. You will need to modify the composer.json file (see below) to add a reference to the gitHub repository.

In the file composer.json:

  "repositories": [
    {
      "type": "package",
      "package": {
        "version": "dev-master",
        "name": "sim1984/laravel-firebird",
        "source": {
          "url": "https://github.com/sim1984/laravel-firebird",
          "type": "git",
          "reference": "master"
        },
        "autoload": {
          "classmap": [""]
        }
      }
    }
  ],
        

Use the require section to add the required packages in the following way:

  "zofe/rapyd": "2.2.*",
  "sim1984/laravel-firebird": "dev-master"
        

Now you can start updating the packages with the following command, which must be started in the root directory of the web application:

  composer update
        

On completion of that command, the new packages will be installed in your application.

Configuration

Now we can get down to configuration. To get it started, execute the following command to create additional configuration files for the zofe/rapyd package:

  php artisan vendor:publish
        

We add two new providers to the file config/app.php by adding two new entries to the providers key:

  Zofe\Rapyd\RapydServiceProvider::class,
  Firebird\FirebirdServiceProvider::class,
        

We proceed to the file config/databases.conf (not to be confused with databases.conf in your Firebird server root!) that contains the database connection settings. Add the following lines to the connections key:

  'firebird' => [
    'driver' => 'firebird',
    'host' => env('DB_HOST', 'localhost'),
    'port' => env('DB_PORT', '3050'),
    'database' => env('DB_DATABASE', 'examples'),
    'username' => env('DB_USERNAME', 'SYSDBA'),
    'password' => env('DB_PASSWORD', 'masterkey'),
    'charset' => env('DB_CHARSET', 'UTF8'),
    'engine_version' => '3.0.0',
  ],
        

Since we will use our connection as the default connection, specify the following:

  'default' => env('DB_CONNECTION', 'firebird'),
        

Pay attention to the env function that is used to read the environment variables of the application from the special .env file located in the root directory of the project. Correct the following lines in the .env file:

  DB_CONNECTION=firebird
  DB_HOST=localhost
  DB_PORT=3050
  DB_DATABASE=examples
  DB_USERNAME=SYSDBA
  DB_PASSWORD=masterkey
        

Edit the config/rapyd.php configuration file to change the date and time formats to match those used in your locale:

  'fields' => [
    'attributes' => ['class' => 'form-control'],
    'date' => [
      'format' => 'Y-m-d',
    ],
    'datetime' => [
      'format'   => 'Y-m-d H:i:s',
      'store_as' => 'Y-m-d H:i:s',
    ],
  ],
        

That completes the initial configuration. Now we can start building the logic of the web application.

Prev: Installing LaravelFirebird Documentation IndexUp: Developing Web Applications with PHP and FirebirdNext: Creating Models
Firebird Documentation IndexFirebird 3.0 Developer's GuideDeveloping Web Applications with PHP and Firebird → Creating a Project