Include files with friendly URL

Asked

Viewed 153 times

1

I’m using URL friendly on my website, I include the files on index.php everything correctly, and it works in my filing cabinet pages/register.php straight.

Only when I access directly with the url http://localhost/treinos/pages/register.php

The server accuses me of this error:

Fatal error: Class 'Cadastro' not found in C:\wamp\www\treinos\pages\register.php on line 2

This error only occurs if I directly access the file, it normal including with the URL friendly don’t accuse error, someone would know why the hell this is happening... ?

  • what the problem ? you want when accessing the file directly, to work include or be blocked?

  • That works include normally as if you were accessing normal!

  • show url rewrite rule.. edit and include in the query

  • 1

    I decided to include in the file "pages/register.php" that require_once(dirname(__DIR__)."/modules/Config.php");
require_once(dirname(__DIR__)."/modules/class/Connection.class.php");
require_once(dirname(__DIR__)."/modules/class/Cadastro.class.php");

1 answer

0

Try to use the pattern PSR-4 for autoload of classes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.