Skip to content

Faster and more secure solution #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
joanhey opened this issue Oct 18, 2022 · 0 comments
Open

Faster and more secure solution #3

joanhey opened this issue Oct 18, 2022 · 0 comments

Comments

@joanhey
Copy link

joanhey commented Oct 18, 2022

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();
         ';
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant