So recently I try to make php MVC, and then I do boostrapping method for load classes to /public/index.php
, when i was done with the boostrapping,I do simple testing which I try to perform the __construct()
method inside the App class in /app/core/App.php
, but when I open /public/index.php
in browser,nothing happend, and I try to echo something inside /public/index.php
just same, nothing happend
But when i remove the require_once "../app/init.php";
, the echo just work perfectly, i have no idea what happend :(, please show me what's wrong with my code and why it can happend
My goal :
- make sure that my boostrapping correct
- to perform echo in browser for checking that the boostrapping success
Expected result :
- echo a string from App's
__construct()
to browser
My code :
- Inside
/app/core/App.php
<?php
class App{
public function __construct(){
echo "ok!";
}
}
- Inside
/app/init.php
<?php
require_once 'core/App.php';
require_once 'core/Controllers.php';
- Inside
/public/index.php
<?php
require_once '../app/init.php';
$app = new App;
echo "test";
Edit : Errors message
Warning: require_once(./core/App.php): Failed to open stream: No such file or directory in /opt/lampp/htdocs/phpmvc/app/init.php on line 3
Fatal error: Uncaught Error: Failed opening required './core/App.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/phpmvc/app/init.php:3 Stack trace: #0 /opt/lampp/htdocs/phpmvc/public/index.php(3): require_once() #1 {main} thrown in /opt/lampp/htdocs/phpmvc/app/init.php on line 3