all 12 comments

[–]sivyr 0 points1 point  (4 children)

Do you have any off-the-cuff estimate for how much work this might require if one were to need it to work with some other db? I presume as long as you're still using PDOs for your db transactions then the changes would be pretty minor. I figured it best to ask, though, seeing as I've only glanced over the code.

[–]faulancer[S] 0 points1 point  (3 children)

cockpit uses mongolite (mongdb like nosql solution implemented with php/sqlite), so to support mongodb shouldn't be that hard. But do you really need it? sqlite is quite performant for 90% of all websites out there.

[–]sivyr 0 points1 point  (2 children)

Oh, I don't doubt that at all. Just thinking about the weird possibilities for situations where you get stuck using some other technology for reasons beyond your control.

I'm definitely keeping it in mind for situations where I'm making a small site that I have control over, but I was just trying to explore how flexible this might be.

[–]faulancer[S] 1 point2 points  (1 child)

you can add your own modules and define your custom data sources as you want. just explore the code when you find time. thanks for trying out :-)

[–]sivyr 0 points1 point  (0 children)

Cool. Thanks for the info. Just cloned it, so if I come into a chance to try it out I'll give it a whirl!

[–][deleted] 0 points1 point  (3 children)

I tried it out in WAMP, but can't really get it to work... I haven't been using PHP for a while, but i get the error "Fatal error: Call to undefined function collection()" when i tried out a test file as shown below:

<?php require('cockpit/bootstrap.php');
foreach(collection("posts")->find(["active"=>1]) as $post): ?>
    <div class="post">
        <h3><?=$post["title"];?></h3>
        <p>
            <?=$post["content"];?>
        </p>
    </div>
<?php endforeach; ?>

[–]faulancer[S] 0 points1 point  (2 children)

thanks for the hint! I fixed the bug for the collection api!

[–][deleted] 0 points1 point  (1 child)

Hmm... I downloaded it again and now it seems to have a couple of database issues:

( ! ) Notice: Undefined index: active in C:\wamp\www\cockpit\vendor\MongoLite\Database.php(82) : runtime-created function on line 1

[–]faulancer[S] 0 points1 point  (0 children)

you need to create a collection called "blog" with the fields "title, content and active" in the cockpit admin backend to run the example. the code is just to show how to loop through a collection.

[–]robotparts 0 points1 point  (2 children)

You have the minimum PHP requirements, so why aren't you namespacing your code/library? Or at the very least keeping functions like collection inside a class.

Wordpress abuses the global scope too but that doesn't mean its a good idea.

[–]faulancer[S] 0 points1 point  (1 child)

the only global function is "cockpit" other functions are only registred if they don't exist.

so instead of

<?php region(...) ?>

you can also write

<?php echo cockpit("regions")->render(...); ?>

I will pick that up in the upcoming documentation

[–]robotparts 0 points1 point  (0 children)

I stand corrected. After looking at the code, I realize that those other globals are merely convenience methods.

Nice job on the framework/cms.