Proyectos de Subversion LeadersLinked - Services

Rev

Rev 41 | Rev 43 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
9 efrain 5
 
1 efrain 6
use Laminas\Mvc\Application;
7
use Laminas\Stdlib\ArrayUtils;
8
 
42 efrain 9
if (isset($_SERVER['HTTP_ORIGIN'])) {
10
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
11
    header('Access-Control-Allow-Credentials: true');
12
    header('Access-Control-Max-Age: 86400');    // cache for 1 day
13
}
14
 
15
// Access-Control headers are received during OPTIONS requests
16
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
17
 
18
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
19
        header("Access-Control-Allow-Methods: GET, PUTH, PATCH POST, OPTIONS");
20
    }
21
 
22
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
23
            header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
24
    }
25
    exit(0);
26
}
27
 
1 efrain 28
/**
29
 * This makes our life easier when dealing with paths. Everything is relative
30
 * to the application root now.
31
 */
32
chdir(dirname(__DIR__));
33
 
34
// Decline static file requests back to the PHP built-in webserver
35
if (php_sapi_name() === 'cli-server') {
36
    $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
37
    if (is_string($path) && __FILE__ !== $path && is_file($path)) {
38
        return false;
39
    }
40
    unset($path);
41
}
42
 
43
// Composer autoloading
44
include __DIR__ . '/../vendor/autoload.php';
45
 
46
if (! class_exists(Application::class)) {
47
    throw new RuntimeException(
48
        "Unable to load application.\n"
49
        . "- Type `composer install` if you are developing locally.\n"
50
        . "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n"
51
        . "- Type `docker-compose run lamians composer install` if you are using Docker.\n"
52
    );
53
}
54
 
55
// Retrieve configuration
56
$appConfig = require __DIR__ . '/../config/application.config.php';
57
if (file_exists(__DIR__ . '/../config/development.config.php')) {
58
    $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');
59
}
60
 
61
// Run the application!
62
Application::init($appConfig)->run();