Le mardi 22 janvier 2013 16:31:37 UTC-5, cricket a écrit :
On Tue, Jan 22, 2013 at 8:30 AM, Frank Fournier
<frank.f...@gmail.com> wrote:
> Hi all,
>
> I am just starting with PHP and CakePHP... I have installed CakePHP with a
> Softaculous script from my web host provider.
>
> I also made the "Blog Post" tutorial work.
> (http://book.cakephp.org/2.0/en/index.html#build-a-blog )
>
> Q1)
> When I type MyDomain.com/cake all verification stuff works (PHP version ,
> /tmp, MySQL link test , etc.). But what exactly is happening? How is the
> Dispatcher invoked? Are there hooks into PHP and/or Apache? How is this
> magic working?
Dispatcher is invoked at the bottom of app/webroot/index.php where
each request ends up. (More on that below.) It's not clear what you
mean but you can have a look at the Dispatcher class (in
lib/Cake/Routing). Specifically, the dispatch() method.
Basically, at the beginning of this method the EventManager calls
parseParams() which in turn loads the routes. From that it figures out
which controller to hand off the request to.
The entire routing/dispatching has become much more complex of late,
and I'm not clear on everything that's happening so I won't try to
explain it further. If anyone knows of a clear explanation of each
step (Dispatcher, CakeEvents, Routing) please post a link.
> And when I try MyDomain.com/cake/index.php I get error messages...
Can't really help without knowing the error messages, although that
path doesn't look right. It depends on how you plan to use Cake. Will
it run your entire site, or just a subset?
And keep in mind that Cake's "index" is not the same thing as
index.php. The former is part of a route to the index action of some
controller. Both are so named for historical reasons -- the
DirectoryIndex-- the default file which would format a nicer looking
list of files than the browser's default.
So, normally, you'd invoke a Cake controller action like:
/posts/index
/posts/view/44
etc. You can also create custom routes that don't follow this pattern.
Also, notice that there's an index.php at the same level as app, and
one inside as well. Each of these in turn points to the one inside
webroot, which does the heavy lifting. Ditto for the .htaccess files.
These are all there to deal with the situation where you can't set the
DocumentRoot for the webserver.
However, if you do have the rights to edit Apache's config on the
server, it's best to disable .htaccess and set the DocRoot to the
webroot directory:
DocumentRoot /var/www/vhosts/your_site/app/webroot
...
<Directory "/var/www/vhosts/your_site/app/webroot">
AllowOverride None
...
DirectoryIndexindex.php index.html
</Directory>
Obviously, paths will vary according to how you like things on your
server. If you do this you can remove all .htaccess files as well as
the 2 index.php files above webroot.
> Q2) I have the "Blog Post" tutorial working (MyDomain.com/cake/posts/index)
> but how do I mask the tracing information on my working rendered web page?
> (class information + SQL stuff that I want to hide)
That's the output from $this->element('sql_dump') which is in the
layout file. To keep this from appearing set debug to 0 in core.php.
But be warned that any errors Cake encounters will then force a 404
message, which can be baffling to newcomers. Always keep debug > 0
while working on a site.
But it can be annoying when working on a site's appearance. This is a
little JQuery bit I have at the top of all my global js files. It
hides the debug stuff and creates a discrete link to toggle its
display.
$(function()
{
/* Toggle debug
*/
$(".cake-sql-log").hide().before('<a href="#"
id="toggle-cake-sql-log">debug</a>');
$("#toggle-cake-sql-log").click( function()
{
$(".cake-sql-log").toggle();
return false;
});
...
Many thanks Cricket !!! (Frank)
-- Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment