Extending from my own controller |
[eluser]n0xie[/eluser]
You don't need to define anything. It will work automatically. If you put the code in the config add these 2 controllers: Code: // test.php and Code: // test2.php Then point your browser to http://domain.tld/index.php/test2 It should output 'hello'.
[eluser]Agustín Villalba[/eluser]
Ok n0xie! But I have a question about that: That function loads every controller at the system start up, but could be a problem with that, because it could cause an overloading for the server, because if there are many controllers the time while this function loads all the controllers could cause the application runs very slow, don't it? Excuse my poor English! Thank you very much!
[eluser]n0xie[/eluser]
It only loads the controller it needs: http://php.net/manual/en/language.oop5.autoload.php
[eluser]Agustín Villalba[/eluser]
Ok!! It's perfect! I didn't know that function in PHP 5! Sorry about that, and thank you for expend your time solving this problem!!
[eluser]Colin Williams[/eluser]
Since when did including dependencies before a class become "inelegant?" I know you can use __autoload() to invent your own conventions, which is fine, but is including something really so terrible?
[eluser]Agustín Villalba[/eluser]
Oh no no!! Not at all!! All what I mean is that by including files dependencies with "include_once" you have to do it before every class, which implies that you can forget some "include" and you have to repeat many code, but it isn't "inelegant" at all! Don't get me wrong please! You're right too!
[eluser]Alface[/eluser]
[quote author="n0xie" date="1263925356"]You don't need to define anything. It will work automatically. If you put the code in the config add these 2 controllers: Code: // test.php and Code: // test2.php Then point your browser to http://domain.tld/index.php/test2 It should output 'hello'.[/quote] It show me this: Fatal error: Class 'Test' not found in C:\xampplite\htdocs\projetos\forsite\system\application\controllers\test2.php on line 3 PHP Version 5.2.8
[eluser]Phil Sturgeon[/eluser]
[quote author="Alface" date="1273058408"]It show me this: Fatal error: Class 'Test' not found in C:\xampplite\htdocs\projetos\forsite\system\application\controllers\test2.php on line 3 PHP Version 5.2.8[/quote] Did you add the __autoload()? It's not found because you haven't told PHP how to find it. |
Welcome Guest, Not a member yet? Register Sign In |