Skip to content

Faster and more secure solution #3

@joanhey

Description

@joanhey

Before

We saw, how to include all in the index.php

<?php
include_once('config.php');
include_once('template.php');
include_once('whisper.php');

new Whisper();

After

But we can load it in the nginx.conf, so we don't have any php file in the root.
And we don't need to load any php file.
Also we can place the complete file in start.php, because will load only one time, and will not be redeclaration of constants or classes.

start.php (outside of the root)

<?php
require ('config.php');
require ('template.php');
require ('whisper.php');

//or
//require  __DIR__."/vendor/autoload.php";

In the nginx.conf

....
php_ini_path /path/to/php.ini;

init_worker_by_php '
        require "path/start.php";
';

....

location  / {
	 content_by_php '
               new Whisper();
         ';
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions