travelpayouts / flights-api-project

Flights search reference project based on PHP
Other
34 stars 29 forks source link

flights-api-project

This is a standalone app based on Yii2 on backend and angularJs on frontend. It uses Travelpayouts api for retrieving flights information and view search results on a domain or subdomain of your site.

Check out our demo

Requirements

This app using Travelpayouts flights search API, to access the flights search API you should be registered in our travel affiliate program and submit your request on support@travelpayouts.com with the following information:

More information about flights search api

After granting access to Travelpayouts flight search Api you need to get your api token and marker here.

Installation

Download and unzip package or clone it to your web folder git clone https://github.com/travelpayouts/flights-api-project.git

Use composer to install dependencies.

Installing Composer

If you do not already have Composer installed, you may do so by following the instructions at getcomposer.org. On Linux and Mac OS X, you'll run the following commands

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

On Windows, you'll download and run Composer-Setup.exe.

Installing Composer packages

Just use command composer install.

Changing your app parameters

Before first running of your app, you need to set app params. All your params is located in config/params.php

<?php

return [
    // set target language
    'language' => 'en-US',
    // set source language
    'sourceLanguage' => 'en-US',
    'params' => [
        'apiToken' => 'e451ad62a0e8468732b6e1ada1e58223', // Token https://www.travelpayouts.com/programs/100/tools/api
        'apiMarker' => '132474', // Marker https://www.travelpayouts.com/programs/100/tools/api
        'apiResponseLang' => 'en', // Response language : en,ru,de,es,fr,it,pl,th.
        'title' => 'TravelPayouts sample app', // Title of your app
        'baseUrl' => '/flights-api-project', // Path of your app (for example: if your project url is http//site.com/flight set 'baseUrl'=> '/flights', if it in root directory set 'baseUrl'=> ''
    ],
];

Setting webserver

server {
    charset utf-8;
    client_max_body_size 128M;

    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    server_name mysite.local;
    root        /path/to/basic/web;
    index       index.php;

    access_log  /path/to/basic/log/access.log;
    error_log   /path/to/basic/log/error.log;

    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php$is_args$args;
    }

    # uncomment to avoid processing of calls to non-existing static files by Yii
    #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    #    try_files $uri =404;
    #}
    #error_page 404 /404.html;

    # deny accessing php files for the /assets directory
    location ~ ^/assets/.*\.php$ {
        deny all;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
        #fastcgi_pass unix:/var/run/php5-fpm.sock;
        try_files $uri =404;
    }

    location ~* /\. {
        deny all;
    }
}

When all these things are done

Congratulations, you completed installation and you can perform your first search.

Developing

Dependencies

What you need to make changes to this app:

Installing packages

Use command npm install to install all package dependencies

Webpack

Use webpack to make changes to all files that you want to change.

To recompile your frontend files you can use a command: npm run build in root directory of your project or npm run start if you don’t want to manually recompile after every change.

Frontend directory structure

Category Location
Webpack config /webpack.config.js
Angular app entry point /frontend/app.js
Components /frontend/components
Controllers /frontend/controllers
Templates /web/templates
Stylesheets (scss) /frontend/scss