Kohana - Authenticating Users? - php

I would like to get started on a simple project using the Kohana 3 framework (looks very promising), but the docs are a bit lacking in my opinion and would like some direction to get my feet wet and get me started. So I have a simple use-case question one that most every application needs.
How would you present a login form with a username and password, capture this, process it and return either fail or success? And how does it keep a user session (object?) persistent? I am new to Kohana with a Drupal background.

Well, there's an Auth module that you can take a look at to see how it works.
You're right about the docs for Kohana 3 being a bit lacking, but I think the developers expect people picking it up to be a bit more experienced and willing to look under the hood.
A few useful resources I've found for learning more about Kohana 3 are the following:
Unofficial kohana 3 wiki
Userguide
a guide to HMVC pattern
kohana 3 tutorial collection
hmvc widget example
source code for an example website written in kohana 3
a blog module for kohana 3
a cms written in kohana 3
Kohana IRC at freenode #kohana-

Take a look at this tutorial. It is on using Kohana_Auth to authenticate users.

Related

Laravel 3 : Looking for explanation how to use the model

I'm new at MVC and my first framework is Laravel (3 for now). I've started coding exclusively in the routes, and I moved to the controller. I'm however doing all of my database operations in the controller. I do not understand how to use the model.
Examples either demonstrate everything in the controller or in the route, but they never split the model, controller and view.
Could anyone kindly explain me how to use the model? In short I don't understand how to link one to each other, like sending form input to them model, or processed data back to the controller.
A github repo of a Laravel (v3 if possible) with a full MVC setup would be nice to analyze too, if anyone has one up for me to look at?
Thanks.
The best statement on the subject of Frameworks I've heard is due to Uncle Bob:
A good Architecture allows major decisions to be deferred!
Specifically:
A good Architecture delays choosing a Framework!
Another great piece to think about:
MVC is not an Architecture! It is a Delivery Design Pattern.
Watch his video - it is one of the sadly few ones out there that don't spend 1000 words on what can be said in 10 and I can't highly enough recommend it - and it will help you to understand many points raised in your question:
Robert C Martin(Uncle Bob) -Clean Architecture and Design - Video
Of course, his book on Clean Code is also highly recommended!
Although this link is for Laravel 4 docs, it may help you understand how the models work - (Laravel 3 also uses Eloquent):
http://laravel.com/docs/eloquent
Also, specific to laravel 3:
http://codehappy.daylerees.com/eloquent-orm

PHP Frameworks for JQUERY/AJAX Client Mainly for Authentication Process and Database Manipulation. Which one?

I'd like to have "PRO" Php developers advice regarding the framework they use , specially for an application that use "mainly" php as authentication process, connector and db data process in relationship with an Ajax/Jquery Client ... I use Zend Framework , but is that framework the lightest solution for that kind of process ?
In my list i have :
Symfony http://symfony.com/get_started
Kohana http://kohanaframework.org/
Ok,
Here are further details on what i need :
I'm developing a website that needs these requirements :
Simple login with classic interface and social ones (facebook, twitter).
When user login , he can just change some parameters on his account (pseudo, password and so on).
Then, the only thing he can do is creating what i will call "objects" that have different properties.
These "objects" can then be share with others through a graphical interface.
Nearly everything on the client side will be just displaying these objects with Jquery/Ajax in relashionship with PHP...
So, i just need PHP for oAuth process and datas manipulations...
I'm trying to find the best solutions regarding this little scenario...
For now, i use Zend Framework on Zend server, it works, but seems to be a little bit "heavy" .. so my question is : is there a better 'lightest' way to consider this ?
Dunno if i'm clear :-/ ...
So, thanks in advance !
Aside agreeing with Gordon, I can see you're just looking for someone to suggest something besides zend.
I would go with Kohana over Symfony because Kohana is much easier to understand out of the box and doesn't require any special setup to work with. It is fast enough to supply you with whatever I assume you need at this level - and by that I mean that if you were building an enterprise level site like ebay you wouldn't be asking this question at all.
You don't need to use the ORM for database interaction but if you decide to it is very easy to understand and will make the development process much faster, even if you don't know the ins and outs of it.
Officially my answer is to agree with Gordon though. If he posts his comment as an answer I will upvote it because you shouldn't just ask the community what they use while providing a tiny list of things you need that almost every site on the planet also uses. It's just too vague.
And yes, I use Kohana all the time. Codeigniter as well if you want another option.
Limonade is another option for very tiny micro-framework. I dislike it for a huge number of reasons but it is not hard to use.

cakephp overviews

I recently started working with CakePHP but there are a few things I don't understand...
What do I have to do to get an overview of a couple of functions/views on one page like 'www.example.com/profile'. I really need help with this I am stuck in thinking in regular procedural php.
First off, you should follow the Blog tutorial on the CakePHP cook book : http://book.cakephp.org/view/1528/Blog
It's a great example and walks you through all the main stuff.
CakePHP follows an MVC structure and maps the URLs to controller/actions (using routes)
In your example www.example.com/profile, if you haven't changed the default routing, actually maps to the index method in your ProfileController. This method uses the view in /views/profiles/index.ctp to display output.
First follow the tutorial and read up on the CookBook to figure out what all this means. It's very easy to learn and they have some good documentation. Also check out code generation in CakePHP. It helps you create your apps faster (if used properly).
You need to read the manual about Routing. Also be familiar with basic Apache knowledge like mod_rewrite.

PHP framework of intermediate complexity, in between CodeIgniter and Yii?

Something easy like CI (this means mandatory good, easy, up to date documentation). But also with some more features than CI.
Yii has lots of features, but it is also more complex (and it kind of forces you to have to use lots of it features). That means adding some functionality to your web-app takes three times as long because you have to figure out lots of new small functionalities of Yii.
It's kind of like the CI "gets out of your way" when it needs to, and Yii gets in your way, and if you don't do it its way, it breaks.
Features missing in CI that would be nice to have in this new "intermediate" PHP framework:
Code generation (crud).
Authentication.
Access control.
Layouts.
Widgets.
Easyer / automated pagination (like yii)
easy uri parameters
Where Yii causes me problems:
It's like for every small task there is some inbuilt functionality (this is good), but, YOU HAVE to use the inbuilt functionality, otherwise bad things happen. (CI gets out of your way, but does it too much, Yii helps a lot, but is butting in too much at times, and it forces you to sift through its documentation so that you discover these functions without which you are not able to accomplish a task that would take four time less, in CI, or in a non framework app).
Is there something in between ?
(ASP.NET MVC could be 'it', but I don't know the language, so the effort to learn it would be greater than learning Yii php framework really well, so I am looking for a PHP Framework)
I am a fan of CakePHP. I feel it has the specs you provided. If you want something more cutting edge you can take a look at Lithium
I have found some resources that kindof solve the problem, because they contain examples (Milan Babuškov's sugestion helped focus on "the solution").
Yii playground - examples
Yii cookbook - examples
Yii blog tutorial - more examples
PS. there is also google - I find solution (and examples) the fastest this way - ex: implement + pagination + yii
I've used both CI and Yii (on my own projects if that makes any difference). CI was my first introduction to MVC, and I found it easy going because it let me use any crappy structure and code. I wrote two full sites in CI (www.insolvencynews.com and www.thebigeat.com if you want to see complexity.)
I had a look at CakePHP but got NOWHERE.
Then I moved on to Yii and, like you, I found it pretty tough and rigid. But I then found that it was so powerful and extensible that I was so much more efficient. When I needed to add a few new features to the old CI sites, it was faster to rewrite the entire sites on Yii than to code up the extra features in CI.
I can't recommend a framework in the middle, but I can recommend sticking with Yii. When you say Yii gets in the way, can you give an example? Looking at DB stuff (in ascending order of dependence on Yii):
you can code using PHP's core MySQL functions.
$result = mysql_query($sql);
you can use Yii's DB abstraction layer.
Yii::app()->db->createCommand($sql)->queryAll();
You can use Yii's ActiveRecord:
Takeaway::model()->findAll();
you could try kohana (especially coming from ci)
You should check out the CI community, some of those extensions maybe have been written by someone else (I remember seeing Authentication and Components/Widgets somewhere)
Symfony is worth checking out. I personally don't like it much because they chose Prototype over jQuery for their ajax features, which is really annoying to use when you're used to jQuery.
Lithium might be good to check out too. However, it is php 5.3 only and you need to be really careful that this version of PHP is going to be supported on the server the site will be deployed on.
See this list for good comparisson:
http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#PHP_2
From a personal point of view, I would go with symfony because of it's
rich features and
great integration with many other already bundeled components (Doctrine, Swift Mailer,..),
good (but at first complex) code generation that produces realy useable code to get you startet quickly,
powerfull use of templating (that will be the point you mention under "layouts)
many different, powerfull plug-ins, including Authentication & Access Control (it also has a plug-in to get jQuery support)
one of the best tutorials that I've seen with a framework
Downside is a
more complex structure,
IMO wired file structure,
a rather messy API documentaion compared to the tutorial
CodeIgniter is a nice framework if you don't want to create big apps but it lacks a great database integretaion and you already mentioned code generation.
im very good in Raw PHP, where the project at hand became too much to handle i decided to move to zend, with too too much complexity i finally moved to YII which really reduced the cost and overhead time for project development and most importantly for me is the simple integration of jquery, widget and advanced-OOP.
You could have a look at Qcodo / Qcubed.
They are both easy to pick up and offer code generation / ORM
Easy way to create forms in an mvc kind of way.
For what its worth, if you're looking for a PHP Framework that is like ASP.NET MVC then I think Prado is the closest thing you will find.

Is there any skeleton project made with Kohana that makes use of authentification and database?

To get started with Kohana quickly, I wonder if someone has ever made an sleek skeleton project that makes use of all basic things every web developer needs:
basic user authentification with login
retrieving some stuff from an MySQL database and displaying it
By hand I would do this pretty fast. But with Kohana it feels like I have to climb up the Mont Everest to achieve it. They don't provide any complete examples, just code fragments for all kind of stuff. It would be cool to have some "basic shape" from where to start making an dynamic platform. I mean, nowadays alsmost every website needs to have some kind of authentification, login and stuff like this.
If anyone knows a simple basic working skeleton project example that's not blown up with tons of freak stuff like ajax & co, a link would be cool.
This project/tutorial looks like it'd be worth checking out: http://remorse.nl/weblog/kohana_auth_module_a_better_one/. It was written by someone who wasn't very happy with the default auth module in Kohana.

Categories