Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6244289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:18:03+00:00 2026-05-24T12:18:03+00:00

I just started to play with the PHP framework lithium (v 0.10). I followed

  • 0

I just started to play with the PHP framework lithium (v 0.10).
I followed the quick start manual which uses MongoDB as database.
To learn a bit more about lithium, I wanted to switch the DBMS from MonogoDB to MySQL.

The problem I’m having that when I open /posts/ in the browser lithium only shows a blank page with no error messages. Also, when I go to /posts/add/, the correct form is displayed, but after submitting the data (which is correctly written to the DB), lithium also just displays a blank page. What’s going wrong?

Also, after reading the lithium docs on models in lithium, I’m still not quite sure what logic (in this case) belongs to the model.

UPDATE 1:

I looks like it there is a problem with the APC caching. After installing APC and renaming the folder containing the lithium, the application worked without an error. When leaving the name of the folder containing lithium unchanged, I got an cache error:

Warning: include(/var/www/web/frameworks/lithium/app/resources/tmp/cache/templates/template_views_layouts_default.html_886_1308416958_798.php) [function.include]: failed to open stream: No such file or directory in /var/www/web/frameworks/lithium/libraries/lithium/template/view/adapter/File.php on line 111

Warning: include() [function.include]: Failed opening '/var/www/web/frameworks/lithium/app/resources/tmp/cache/templates/template_views_layouts_default.html_886_1308416958_798.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/web/frameworks/lithium/libraries/lithium/template/view/adapter/File.php on line 111

END UPDATE 1

I manually set a up a MySQL table posts with the rows id, title and body.

My Posts.php model in /app/models:

<?php
namespace app\models;

class Posts extends \lithium\data\Model {

}
?>

My PostsController.php controller in /app/controllers:

<?php

namespace app\controllers;

use app\models\Posts;

class PostsController extends \lithium\action\Controller {


    public function index() {
        $posts = Posts::all();
        return compact('posts');
        var_dump($posts);
    }

    public function add() {
        if($this->request->data) {
            $post = Posts::create($this->request->data);
            $success = $post->save();
        }
        return compact('success');
    }
}
?>

And finally my views index.html.php in /app/views/posts/:

<?php foreach($posts as $post): ?>
<article>
    <h1><?=$post->title ?></h1>
    <p><?=$post->body ?></p>
</article>
<?php endforeach; ?>

And also add.html.php in /app/views/posts/:

<?=$this->form->create(); ?>
    <?=$this->form->field('title');?>
    <?=$this->form->field('body', array('type' => 'textarea'));?>
    <?=$this->form->submit('Add Post'); ?>
<?=$this->form->end(); ?>

<?php if ($success): ?>
    <p>Post Successfully Saved</p>
<?php endif; ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:18:04+00:00Added an answer on May 24, 2026 at 12:18 pm

    A couple of tips …

    1) Are you sure Lithium is running correctly in general? I’m confused as to what your actual question / problem is.

    2) There is no need to make the change to your PostsController, Posts::all(); is just shorthand for Posts::find('all');

    3) You may need to change your Model for Posts, Lithium (with MySQL) will expect an id column in your table to use as a key, if you don’t have a coloum named id you might need to add one to your model.

    For example, if you have a table with columns like postid, title, body, date … add this to your model

    <?php
     namespace app\models;
    
     class Posts extends \lithium\data\Model { 
       public $_meta = array('key' => 'postid');        
     }
    
    ?>
    

    Note the ‘key’ => ‘postid’ that will let lithium know to use postid as the key for the table instead of looking for id

    4) Here’s how to actually construct a MySQL query in your controller …

    public function locations($companyid,$state=null) {
    
     /* removes null or false values with array_filter() */
     $conditions = array_filter(array('companyid' => $companyid, 'state' => $state));
    
     /* pass $conditions array to the Locations model, find all, order by city */
     $locations = Locations::find('all', array( 
           'conditions' => $conditions,
           'order' => array('city' => 'ASC')
     ));
    
     return compact('locations');
    
    }
    

    Check out the Lithium Manual for more help: http://li3.me/docs/manual

    Models

    http://li3.me/docs/manual/working-with-data/using-models.md

    Controllers

    http://li3.me/docs/manual/handling-http-requests/controllers.md

    Views

    http://li3.me/docs/manual/handling-http-requests/views.md

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started to play around with MongoDB (C#) and tried to port a
I've just started playing with Play! framework, and stumbled on such problem: modules that
I've just started with the Play Framework and I'm running into some problems using
I just started to use the Play framework and Scala. What does body: =>
I've just started having a play with Kohana, coming from CodeIgniter and straight php.
I just started to play with the entity framework, so I decided to connect
I've just started to play with CodeIgniter 1.7.2 and imendialtly noticed that there is
I just started to play with android dev and java+eclipse is pretty new to
I have just started to learn the very basics of Java programming. Using a
I´ve just started to test, use and play with facebook apps. I´ve searched stackoverflow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.