Welcome Guest, Not a member yet? Register   Sign In
New Code Igniter tutorial series
#11

[eluser]Pascal Kriete[/eluser]
[quote author="onejaguar" date="1211257713"]What do you mean "initialize" itself? Doesn't that happen automatically? You only need to do your own constructor if you want to do something special EXTENDING the default initialization. You can do all the $this-> you want simply because you are extending the base controller.[/quote]

The CI_Controller constructor calls a function named _ci_initialize, which is what wd meant with "initialize". Sure you can run your app without calling the parent constructor, but you cannot call any ci classes. That's because the loader is instantiated in the initialize function, and all the globals created in CodeIgniter.php are tied to the current object.

Job well done though.
#12

[eluser]sikkle[/eluser]
good initiative, hope you will keep working on that.

see ya around.
#13

[eluser]onejaguar[/eluser]
[quote author="inparo" date="1211280934"]
The CI_Controller constructor calls a function named _ci_initialize, which is what wd meant with "initialize". Sure you can run your app without calling the parent constructor, but you cannot call any ci classes. That's because the loader is instantiated in the initialize function, and all the globals created in CodeIgniter.php are tied to the current object.[/quote]

Not true, you don't need to call it.

Code:
function ControllerName()
  {
    parent::Controller();
  }

is superfluous unless you want to do extra things in the constructor because it will happen automatically when your are extending the main Controller class. Unless you need to do this in PHP4? I switched to PHP5 before adopting CodeIgniter.

Don't mean to derail the thread, I just want to make sure I understand this right.
#14

[eluser]Pascal Kriete[/eluser]
Oh gee. You are right actually, it's handled similarly to how java does it. You only need to call the parent constructor if you override it. Really sorry for the thread-jacking.
#15

[eluser]Dam1an[/eluser]
Don't worry about the thread-jacking, as long as its all cleared up.
In future, could you post any comments with regard to a specific part of the tutorial in the comments section of that page, so that everyone can see them, as not everyone that views that post will visit this thread, although any further tips regarding the overall tutorial series, the style, structure, content etc should still go here.

Thanks guys
#16

[eluser]Référencement Google[/eluser]
Dam1an, be sure to add your link in my CI directory: www.codeigniterdirectory.com
#17

[eluser]Dam1an[/eluser]
[quote author="elitemedia" date="1211331762"]Dam1an, be sure to add your link in my CI directory: www.codeigniterdirectory.com[/quote]

Thanks for pointing that out, I've added it now, thats a nice collection of resources you have there.
#18

[eluser]bennyhill[/eluser]
[quote author="Daniel Moore" date="1211244409"]Dam1an,

Always great to see tutorials up that are needed to help people get up to speed on CodeIgniter.

If I may quote you, you said, "Be as harsh as you can, as the more you point out, with regard to Codeigniter and the style of the tutorial, the better it will be for everyone." (If I can't quote you, well you still said it.)

As I assume you are looking for "constructive" criticism so that you can make it the best possible tutorial for all users, I have noticed something in your .htaccess tutorial that could use addressing.

Your .htaccess tutorial will not work for all installations for CodeIgniter. Everyone I work with, and many people in the hard core programming world, prefer the added security of placing the /system directory outside the web root, and some have multiple code igniter applications at a particular site. You have written the following rewrite rule:
Code:
RewriteRule ^(.*)$ /index.php/$1 [L]
This will not work for many installations, as it assumes the index.php is in the root directory, which it is not always in the root, especially on development machines where you may be developing multiple CI applications. It would be better to write it as:
Code:
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
As you can see, I use a dot before the slash before the index.php to tell the rewrite rule to look relative to the current directory. It works flawlessly.

I work on multiple servers, with multiple versions of apache. Some older versions do not behave well with the .htaccess you have, and and this issued has been solved across all apache servers by using the following .htaccess file:
Code:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

Good luck with the tutorial series![/quote]

I copy and pasted your code into an .htaccess file and placed it in the root folder of my website. I made sure that in my http.conf file that I had "AllowOverride all" set properly. Also, I edited the config.php file as you requested. However, I get a 500 error page. When I remove the .htaccess file from my website root and refresh the browser everything works fine. Is there and error with this .htaccess file?
#19

[eluser]bennyhill[/eluser]
[quote author="bennyhill" date="1211914500"][quote author="Daniel Moore" date="1211244409"]Dam1an,

Always great to see tutorials up that are needed to help people get up to speed on CodeIgniter.

If I may quote you, you said, "Be as harsh as you can, as the more you point out, with regard to Codeigniter and the style of the tutorial, the better it will be for everyone." (If I can't quote you, well you still said it.)

As I assume you are looking for "constructive" criticism so that you can make it the best possible tutorial for all users, I have noticed something in your .htaccess tutorial that could use addressing.

Your .htaccess tutorial will not work for all installations for CodeIgniter. Everyone I work with, and many people in the hard core programming world, prefer the added security of placing the /system directory outside the web root, and some have multiple code igniter applications at a particular site. You have written the following rewrite rule:
Code:
RewriteRule ^(.*)$ /index.php/$1 [L]
This will not work for many installations, as it assumes the index.php is in the root directory, which it is not always in the root, especially on development machines where you may be developing multiple CI applications. It would be better to write it as:
Code:
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
As you can see, I use a dot before the slash before the index.php to tell the rewrite rule to look relative to the current directory. It works flawlessly.

I work on multiple servers, with multiple versions of apache. Some older versions do not behave well with the .htaccess you have, and and this issued has been solved across all apache servers by using the following .htaccess file:
Code:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

Good luck with the tutorial series![/quote]

I copy and pasted your code into an .htaccess file and placed it in the root folder of my website. I made sure that in my http.conf file that I had "AllowOverride all" set properly. Also, I edited the config.php file as you requested. However, I get a 500 error page. When I remove the .htaccess file from my website root and refresh the browser everything works fine. Is there and error with this .htaccess file?[/quote]

Sorry, I forgot to load the mod_rewrite module. .htaccess works now. Thanks
#20

[eluser]Unknown[/eluser]
Hello, I have tried this code for several times. It doesn't work in my linux account and window xampp server.

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]



For my linux account,

I need to add a line
RewriteBase /~myusername/ci/
after the line RewriteEngine on, otherwise I will get an error message

Not Found

The requested URL /home/username/www/ci/index.php/hello was not found on this server.



And for my localhost, I am sure that xampp url rewrite function is working.
I have made a test on the other directory and it's working.

RewriteEngine on
RewriteBase /ev/
RewriteRule welcome index\.php [T=application/x-httpd-php]


But I put the following code, http://localhost/ci/hello doesn't work at all.

DirectoryIndex index.php
RewriteEngine on
RewriteBase /ci/
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]


Any suggestion, what's wrong with it? Thanks a lot.




Theme © iAndrew 2016 - Forum software by © MyBB