Jump to content


- - - - -

Create Your Own MVC (Part 1) , help needed


8 replies to this topic

#1 rasse

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 February 2012 - 12:20 PM

I watched all Zen frameworks videos, they where great(ep.1-4). thx. for those, but now I have a problem creating my own MVC.

I get errors when using require $url path. (Undefined index: url in)...
http://youtu.be/Aw28-krO7ZM?t=4m5s

Or before require if I use string mvc.local:8081/index, but mvc.local:8081/someparameter works just fine.

I think the problem something wrong with my php.ini
[Edit]Deleted php.ini

or
httpdv-hosts file
#second Domain, Create Your Own MVC
NameVirtualHost mvc.local
<VirtualHost 127.0.0.1:8081>
ServerName mvc.local
ServerAlias mvc.local
DocumentRoot C:/Sites/mvc/public
ErrorLog "C:/Sites/mvc/error.log"
CustomLog C:/Sites/mvc/access.log common
<Directory "C:/Sites/mvc/public">
	Options -Indexes FollowSymLinks MultiViews
	AllowOverride All
	<IfModule mod_access.c>
	Order allow,deny
	Allow from all
	</IfModule>
</Directory>
</VirtualHost>

When I download your files and try it out on same folder, I still get an error, and the index query problem.
PHP error.
[Wed Feb 22 18:08:52 2012] [error] [client 127.0.0.1] PHP Notice:  Undefined index: url in C:SitesmvcpubliclibsBootstrap.php on line 7
[Wed Feb 22 18:08:52 2012] [error] [client 127.0.0.1] PHP Stack trace:
[Wed Feb 22 18:08:52 2012] [error] [client 127.0.0.1] PHP   1. {main}() C:Sitesmvcpublicindex.php:0
[Wed Feb 22 18:08:52 2012] [error] [client 127.0.0.1] PHP   2. Bootstrap->__construct() C:Sitesmvcpublicindex.php:9

Can u guys figure it out?
I have google like 3-4h :angry:, and now I needed to come here... All help, mucho appreciated!

#2 Zoopstud

    Advanced Member

  • Members
  • PipPipPip
  • 176 posts
  • LocationWales, UK

Posted 22 February 2012 - 01:01 PM

You have set the virtual host to port 8081 and the address to my.local, and you are trying to access it via mysite on port 80.
The more you learn, the more you realize how little you know…

#3 rasse

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 February 2012 - 01:37 PM

sorry was a bit sloppy there. mvc.local:8081/index or mvc.local:8081/someparameter
I can access the site, but I get some php errors there.

my other site zend.local:8081 works fine.. (for now I have commented out include_path = ".:ZendPath") cuz I thought the problem was there.

#4 rasse

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 February 2012 - 01:56 PM

with this index.php code
<?php
$url = $_REQUEST['url'];
print_r($url);
//$controller = new $url;

it gives me this error
Posted Image

and when change the parameter to test it works fine

Posted Image

#5 rasse

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 February 2012 - 02:20 PM

test controller seems to work

mvc/index.php
<?php
$url = $_GET['url'];
require 'controllers/'.$url.'.php';
//$controller = new $url;
$test = new $url;
$test->test();

mvc/controllers/test.php
<?php
class Test {
	function __construct() {
	  
		echo "test constructor<br />";
	}
  
	public function test(){
	  
		echo "test";
	}
}

but when i try with the mvc.local:8081/index

Posted Image

mvc/public/controllers/index.php

<?php
class Index {
	function __construct() {
	  
		echo "index constructor<br />";
	}
  
	public function test(){
	  
		echo "index";
	}
}

if I comment out from .htaccess # RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

and write instead index.php?url=index it works fine.

What have I missed?

#6 rasse

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 February 2012 - 02:48 PM

http://jream.com/for...8-mvc-tutorial/

There is someone else who has the same problem, no answer :angry:

#7 rasse

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 February 2012 - 03:04 PM

I fixed the problem
I had in my virtual host
Options -Indexes FollowSymLinks MultiViews

when I commented it out, it works.

#8 Tpojka

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 06 March 2012 - 08:56 AM

There is some more problems I have to describe in this topic.
I am new to oo php but I try to figure out how it works. And I think founder who I'll call jream :angry: has huge knowledge in that. It is clearly seen in his speed of assuming if have fail/errors in code.

I am in problem not big kind, but I am not able to get error message without calling __contruct function from error class.
Just declaring $controller as an new Error(); class doesn't working for me like in video.
It is on this point.
Is there something I forgot?


Best regards,
www.tpojka.com

edit() {
I started all over and now it is functional; :)
}

#9 kielbasa

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 11 March 2012 - 11:16 AM

:angry: in the next tutorial jream goes over setting default controllers which were not defined. Hence the errors