Well, I tried this weekend to get cake running on Windows IIS7, MySQL
and PHP.  It works fine with a fresh install and making a new
controller, model and view.  Works fine with Apache on Windows too
but, I am seeing a recurring pattern here.

If I extend the AppController by placing another app_controller.php
file into the app directory and put var $components =
array('Session');  then in function beforeRender(){ $this->Session-
>check('some_key'); } I get this error:
[Mon Nov 19 10:36:34 2007] [error] [client 192.168.1.100] PHP Fatal
error:  Call to a member function check() on a non-object in C:\\apache
\\htdocs\\app\\app_controller.php on line 82

Doesn't matter if it's apache or iis, that's the error that persists.
Apache on Windows, I have mod_rewrite enabled in httpd.conf and I have
the AllowOverride settings to All.

Now, I also set up another Linux box with apache mysql and php, just
copied over the site and voila. Works fine!

The only difference is that one is on Windows and the other is on
Linux.

I am going to paste what's in my app controller.php here so, this post
may get a little long.

<?php
class AppController extends Controller
{
    /**
     * Adding Ajax and Javascript helpers to the default helpers.
     * This will load them on the home page.
     *
     * @var Array Holds the names of the helpers to be loaded by
default
     */
    public $helpers = array('Html',
                                            'Ajax',
                                            'Javascript',
                                            'MenuDisplay',
                                            'Banners',
                                            'DraggableBox',
                                            'FormatCategories',
                                            'Session',
                                            'HeaderSearch',
                                            'TextImage',
                                            'TodaysHotProp',
                                            'classifiedGlance',
                                            'AdminHelper',
                                            'Number',
                                            'Form',
                                            'Pdf');

    public $uses = array('Menu', 'Category', 'HotProp', 'Classified',
'WvdBanner', 'Edition','Banner');

    public $components = array('Cookie', 'Session', 'Apphtml',
'MyAuth');

    /**
     * Changing the default extension of templates to php.
     *
     * @var String Holds the default extension of template files.
     */
    public $ext = '.php';

    /**
     * Setting the default pagination properties.  Mainly for
classifieds.
     *
     * @var Array Holds the default pagination limits
     */
    public $paginate = array('limit' => 20, 'page' => 1);

    /**
     * Setting the default theme
     *
     * @var String The default theme
     */

    private $current_theme = 'blue';

    /**
     * This method overrides the basic method from
Controller::beforeRender()
     * There are certain things that every view needs in order to
display
     * correctly so, we set those values here, right before the page
renders.
     *
     * @internal We can also set a beforeFilter if we need to shut the
site down
     */
    public function beforeRender()
    {
        // I get the error here for $this->Session->check();
        /**
         * Get rid of the callback when not on the users controller
         *
         * @todo Add more controllers later on if needed
         */
        if(($this->params['controller'] != "users") &&
             $this->Session->check('callback'))
        {
            $this->Session->del('callback');
        }
        // Every view has the side menu, get the links and set them in
an array for the view
        $this->set('menuArray', $this->Menu->getMenuItems());
        // We set recursive to 0 because we don't want unnecessary
data
        $this->Category->recursive = "0";
        // We get the classified categories for the Quick Links box
        $this->set('categories', $this->Category->findAll());
        $this->set('edition', $this->Cookie->read('edition'));

        //Get the data for the Today's Hot Prop View

        $rMax = $this->HotProp->getNumRows();
        srand(date('His'));
        $randomNumber = rand(1, $rMax);
        $this->set('randomHotProp', $this->HotProp-
>findById($randomNumber));

        /**
         * Do some stuff for crumbs
         */
        $this->Apphtml->addCrumb('Home', '/');
        if($this->params['controller'] != "pages")
        {
            $this->Apphtml->addCrumb(Inflector::camelize($this-
>params['controller']), DS.$this->params['controller'].DS);
            if($this->params['action'] != "index")
            {
                $this->Apphtml->addCrumb(Inflector::camelize($this-
>params['action']), DS.$this->params['controller'].DS.$this-
>params['action'].DS);
            }
        }
        $this->set('crumbs', $this->Apphtml-
>getCrumbs("&nbsp;&raquo;&nbsp;"));
    }

    public function beforeFilter()
    {
        // Clean out the old oneby thumbnail images
        $this->CleanTmpOnebys();

        // Check the banner status and set banners to inactive if they
are out of date
        $this->CheckBannerStatusWs();

        // We are going to set the default edition for QuickLinks here
        // 31556926 = 1 year in seconds
        if(is_null($this->Cookie->read('edition')))
        {
            $this->Cookie->write('edition', 'all', true, 31556926);
            $this->Cookie->write('askededition', 0, true, 31556926);
        }

        // If the current theme is not set in a cookie, use the
default and set the cookie
        if(is_null($this->Cookie->read('user_theme')))
        {
            $this->set('current_theme', $this->current_theme);
            // 2592000 is the time in seconds for 30 days
            $this->Cookie->write('user_theme', $this->current_theme,
true, 31556926);
        }
        else
        {
            // The theme was found in the cookie, use it.
            $this->set('current_theme', $this->Cookie-
>read('user_theme'));;
        }
                $this->set('secure', false);
    }

    /**
     * This method will delete the images out of tmp_onebys every
     * 7 days
     *
     * @return Void
     * @access private
     */
    private function CleanTmpOnebys() {
        $clean = false;
                uses('File');
                $file = new File(APP."tmp/clean_time.txt", true);
                $contents = $file->read();
                if(empty($contents)) {
                    $file->write(strtotime("+7 days", strtotime(date('Y-m-d
00:00:00'))));
                    $clean = true;
                } else {
                    if(time() > intval($contents)) {
                        $clean = true;
                    }
                }
                // Perform the purge
                if($clean == true) {
                        uses('Folder');
                $folder = new Folder(WWW_ROOT.'/img/tmp_onebys');
                $files = $folder->read();
                if(is_array($files)) {
                        $files = Set::extract($files, "1.{n}");
                        foreach($files as $key => $value) {
                            $tmp_file = new File(WWW_ROOT.'/img/tmp_onebys/'.
$value);
                            $tmp_file->delete();
                            unset($tmp_file);
                        }
                        $file->write(strtotime("+7 days", strtotime(date('Y-m-d
00:00:00'))));

                }
                }
    }

    private function CheckBannerStatusWs() {
        uses('File');
/**
 * check to see if the banner date file exists, if the file does not
exist create it and set the date of the contents to Next Tuesday ay
12:00pm
 */
        $dateFile = new File(APP."tmp/banner_status_ws.txt", true);
                $handle = $dateFile->read();
                if(empty($handle)) {
                    $dateFile->write(strtotime("next Wednesday 00:00"));
                } else {
// check the time value stored and make sure it is in the next week
                    if(time() > intval($handle)) {
                        $dateFile->write(strtotime("next Wednesday 00:00"));
                        $handle = $dateFile->read();
// Store all banners into an array
                        $arr =  $this->Banner->findAll();
// Loop through the banners and check the status
                                foreach ($arr as $key=> $value) {
                                        if (strtotime( 
$arr[$key]['Banner']['end']) < intval($handle)) {
//                                              echo "ID: 
".$arr[$key]['Banner']['id']. " should be Inactive!
<br />";
                                                $bid = 
$arr[$key]['Banner']['id'];
                                                
$this->Banner->save(array('Banner' => array('id' => $bid,
'status'=> "Inactive")));
//                                              echo $key .  " - ";
//                                              echo $arr[$key]['Banner']['id'] 
. "<br />";
                                        }
                                }
                    }
                }
    }

    private function CheckBannerStatusGs() {
        uses('File');
/**
 * check to see if the banner date file exists, if the file does not
exist create it and set the date of the contents to Next Tuesday ay
12:00pm
 */
        $dateFile = new File(APP."tmp/banner_status_gs.txt", true);
                $handle = $dateFile->read();
                if(empty($handle)) {
                    $dateFile->write(strtotime("next Friday 00:00"));
                } else {
// check the time value stored and make sure it is in the next week
                    if(time() > intval($handle)) {
                        $dateFile->write(strtotime("next Friday 00:00"));
                    }
                }
//      $arr =  $this->Banner->findAll();

    }
}
?>

On Nov 19, 8:31 am, Baz <[EMAIL PROTECTED]> wrote:
> I know that I've run into problems trying to configure Apache, PHP, and
> MySQL separately on Windows.
>
> But the WAMP and XAMPP solutions work (and port) great.  Just ensure you use
> "DS" instead of "/" or "\" and remember that on Windows Apache (or PHP)
> doesn't seem to be case sensitive.
>
> Those are the only problems I've run into with porting to Linux. Never had
> problems the other way around. But if you trying to run on IIS, good luck
> with that.
> --
> Baz Lhttp://www.WebDevelopment2.com/
>
> On Nov 19, 2007 4:47 AM, RichardAtHome <[EMAIL PROTECTED]> wrote:
>
>
>
> > "Apache on Windows does not work"
>
> > I've been developing WAMP sites for a looong time with no problems.
>
> > I think the rumour started because Apache on windows is not
> > 'officially' supported.
>
> > On Nov 19, 6:07 am, "Wayne Fay" <[EMAIL PROTECTED]> wrote:
> > > Sorry for the confusion, I was really responding to the original post,
> > > specifically:
>
> > > > So, the question:
> > > > Since I have followed every single tutorial I could find on the web
> > > > about installing Cake on IIS for the last 3 days (this includes me
> > > > testing if I could just put Apache on Windows which does not work) I
> > > > really have no other choice but to switch frameworks.
>
> > > And I'm just replying to let Christopher know that Windows + Apache +
> > > Mysql + PHP + Cake works great/fine for me and many others. I'm
> > > curious why he says "Apache on Windows does not work"...
>
> > > Wayn
>
> > > On 11/17/07, Baz <[EMAIL PROTECTED]> wrote:
>
> > > > I assumed he was trying to use PHP under IIS.
>
> > > > On Nov 17, 2007 5:06 PM, Wayne Fay <[EMAIL PROTECTED]> wrote:
>
> > > > > I run Apache plus Cake and Mysql on Windows all the time. And
> > servers
> > > > > are generally Apache on Linux. I change the config file at the start
> > > > > of a new project, sync the rest over during development, and
> > > > > everything just works.
>
> > > > > Wayne
>
> > > > > On 11/17/07, Baz <[EMAIL PROTECTED]> wrote:
> > > > > > I say slap WAMP on there and call it a day :D.
>
> > > > > > Sorry dude, it does suck.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to