473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MVC, seems class is not loaded

103 100+
I am attending online course about MVC
https://www.udemy.com/learn-php-mode...ecture/2201044

By idea if I try http://localhost/MVCfirst/public/
it should try to open index.php :
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst\public\index.php
this file requires boostrap file ..\MVCfirst\app\start.php
The boostrap file requires \MVCfirst\vendor\autoload.php
which using composer loads project core functionality, contollers and apps, including file
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst\app\core\App.php

Than on the second line index.php creates an instance of class App from App.php, which constructor should print “Hello world!”.


But than I try http://localhost/MVCfirst/public/ - nothing happens. I mean i do not see "Hello world" on the webpage.
http://localhost/MVCfirst/public/index.php -prints line: "Before requiring start.php, in index.php After requiring start.php, in index.php" Thus seems the mistake is in class initiation, because "Hello wold" and line After initiating class App, in index.php" is not printed.

If i try http://localhost - opens Bitnami welcome page
http://localhost/MVCfirst/ - opens page with directory structure
http://localhost/MVCfirst/public - page is empty, i do not see directory structure (there is css folder)
http://localhost/MVCfirst/app/ - again i can see directory structure with files.

I can not find where is my mistake, seems that url is not translated for method – action, or maybe class is not loaded and thus constructor does not execute.

The question is how to find the mistake and where is the mistake. How to debug MVC?

Directory structure
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst

..\MVCfirst\composer.json

..\MVCfirst\app
..\MVCfirst\app\controllers
..\MVCfirst\app\core
..\MVCfirst\app\core\App.php
..\MVCfirst\app\models
..\MVCfirst\app\views
..\MVCfirst\app\start.php

..\MVCfirst\public
..\MVCfirst\public\css
..\MVCfirst\public\.htaccess
..\MVCfirst\public\index.php

..\MVCfirst\vendor
..\MVCfirst\vendor\composer with several files
..\MVCfirst\vendor\autoload.php


Related files:
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst\public\index.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo "Before requiring start.php, in index.php";
  3. require_once '../app/start.php';
  4. echo "After requiring start.php, in index.php";
  5.  
  6. $app = new App();
  7. echo "After initiating class App, in index.php";
  8. ?>
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst\app\start.php
<?php
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT .'/vendor/autoload.php';
?>
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst\vendor\autoload.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // autoload.php @generated by Composer
  3. require_once __DIR__ . '/composer' . '/autoload_real.php';
  4. return ComposerAutoloaderInitb77b3134bd41be264b6a56ffd220713b::getLoader();
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst\app\core\App.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. class App {
  3.     public function __construct(){
  4.         echo 'Hello World';
  5.         $this->parseUrl()
  6.     }
  7.  
  8.     protected function parseUrl(){
  9.         echo $_GET['url'];
  10.     }
  11. }
  12. ?>
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst\composer.json
Expand|Select|Wrap|Line Numbers
  1. {
  2.     "autoload": {
  3.         "classmap": [
  4.                 "app/core",
  5.                 "app/models"
  6.         ]
  7.     }
  8. }
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\MVCfirst\public\.htaccess
Expand|Select|Wrap|Line Numbers
  1. Options -MultiViews
  2. Options -Indexes
  3.  
  4. RewriteEngine On
  5. RewriteBase /MVCfirst/public
  6.  
  7. RewriteCond ${ENV:REDIRECT_STATUS} ^$
  8. RewriteCond %{REQUEST_FILENAME} !-d
  9. RewriteCond %{REQUEST_FILENAME} !-f
  10. RewriteCond %{REQUEST_FILENAME} !-l
  11.  
  12. RewriteRule ^(.+)$ index.php?url-$1 [QSA,L]
Apr 7 '15 #1
3 2919
gintare
103 100+
The error was in syntax, i forgot the ";" in App.php
It should be: $this->parseUrl();
not: $this->parseUrl()
Apr 7 '15 #2
gintare
103 100+
Still the question remains.
How to debug project?
IS there some way that the mistake place would be found by program and printed to some file or screen or cmd?
Apr 7 '15 #3
gintare
103 100+
http://stackoverflow.com/questions/1...ors-to-display


Inside your php.ini:

display_errors = on

Then restart your web server.
Apr 7 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phoneix | last post by:
Hello , I have a necessity to delete a jar file which is in the CLASSPATH. But JVM locks it after a class.forName() call, even though the class loaded is NOT in the JAR file I want to delete. ( I...
6
by: Outshined | last post by:
I have a class library where just about every class uses its static initializer to register with a central registry object in the same assembly. I am hoping for some sort of Assembly.Load event...
2
by: Robb Sadler | last post by:
I am trying to write several hardware interfaces that would use the same base class and functions and be implemented differently. I don't want to ship all of the interfaces, but want to access...
4
by: Matthew Sajdera | last post by:
All - What I want to do: I want to abstract the navigation between my aspx pages into a Controlling Class. This Class would talk to a collection of Business Objects. The various aspx pages...
2
by: crusell | last post by:
I'm having some problem with my Visual Studio.NET 2003 (.NET 1.1 SP1) install. I am unable to use the web forms designer with any aspx file whose form class inherits from a base class. I'm...
16
by: Java script Dude | last post by:
Creating a method of object (Object.prototype.classOf ...) is not the correct way because of a (as expected) flaw in IE where DOM Elements does not inherit from Object. As a result it is best to...
6
by: Mark Wilden | last post by:
Take a class, RateTableProductCode. It needs to share implementation with other classes, so the common code is placed in a ProductCode class, from which it derives. There needs to be an...
5
by: Jesper Schmidt | last post by:
When does CLR performs initialization of static variables in a class library? (1) when the class library is loaded (2) when a static variable is first referenced (3) when... It seems that...
5
by: Andrew Robinson | last post by:
I have a page that can load a number of different user controls. Each of these user controls inherits from a common base class and the controls are loaded based on application state, status, etc...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.