Proyectos de Subversion LeadersLinked - Services

Rev

Rev 1 | Rev 4 | 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
 
5
use Laminas\Mvc\Application;
6
use Laminas\Stdlib\ArrayUtils;
7
 
8
//define('DIR_URL', dirname(__DIR__));
9
//define('SITE_URL',  'http://'  . $_SERVER['SERVER_NAME'] . '/');
10
//date_default_timezone_set('Etc/GMT+6');
11
 
3 efrain 12
 
13
header('Access-Control-Allow-Origin: *');
14
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
15
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
16
header("Allow: GET, POST, OPTIONS, PUT, DELETE");
17
$method = $_SERVER['REQUEST_METHOD'];
18
if($method == "OPTIONS") {
19
    die();
20
}
21
 
22
 
23
/*
24
 *
25
if (isset($_SERVER['HTTP_ORIGIN'])) {
26
    // should do a check here to match $_SERVER['HTTP_ORIGIN'] to a
27
    // whitelist of safe domains
28
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
29
    header('Access-Control-Allow-Credentials: true');
30
    header('Access-Control-Max-Age: 86400');    // cache for 1 day
31
}
32
// Access-Control headers are received during OPTIONS requests
33
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
34
 
35
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
36
        header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
37
 
38
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
39
        header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
40
 
41
}
42
 */
43
 
1 efrain 44
ini_set('display_errors', '1');
45
ini_set('display_startup_errors', '1');
46
ini_set('log_errors', '1');
47
error_reporting(E_ALL);
48
 
49
 
50
/**
51
 * This makes our life easier when dealing with paths. Everything is relative
52
 * to the application root now.
53
 */
54
chdir(dirname(__DIR__));
55
 
56
// Decline static file requests back to the PHP built-in webserver
57
if (php_sapi_name() === 'cli-server') {
58
    $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
59
    if (is_string($path) && __FILE__ !== $path && is_file($path)) {
60
        return false;
61
    }
62
    unset($path);
63
}
64
 
65
// Composer autoloading
66
include __DIR__ . '/../vendor/autoload.php';
67
 
68
if (! class_exists(Application::class)) {
69
    throw new RuntimeException(
70
        "Unable to load application.\n"
71
        . "- Type `composer install` if you are developing locally.\n"
72
        . "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n"
73
        . "- Type `docker-compose run lamians composer install` if you are using Docker.\n"
74
    );
75
}
76
 
77
// Retrieve configuration
78
$appConfig = require __DIR__ . '/../config/application.config.php';
79
if (file_exists(__DIR__ . '/../config/development.config.php')) {
80
    $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');
81
}
82
 
83
// Run the application!
84
Application::init($appConfig)->run();