Use fuelphp modules without mvc - fuelphp

I've opened a similar question on Zend (Using ZF2 components without entire MVC process) but I wonder if it is possible to use fuelphp without using the MVC elements? It takes a long time to load so could you use forms or access control for example without using the whole mvc system?

Most of v1 is somewhat tightly coupled with the fuel core, so you could use parts of it but you would still have to make sure the autoloader is set up and any parts of fuel that the target code needs. This should not be a major problem with v1 but it is simply not designed to be used like this so YMMV.
What might be a better move is to take a look at the v2 packages as the code is better separated and the packages have minimal dependencies on each other. None of the v2 code relies on the MVC structure apart from the core installer package.
As of the time of writing not all are finished or even started but there might be something in there that you will find useful. We are also going to be releasing a first alpha version of v2 in the new year so there should be lots more code popping up over the next month and a half.
That being said there are loads of packages out there on packigist so there's nothing stopping you using anything from there, totally outside of the MVC pattern.

Related

How to Move Already Written and working project With No Frameworks to Kohana?

I'm curious if it is possible to move the written and fully working project to Kohana step-by-step. I mean if it is possible to replace page by page. So the project will move consequently from 100% of non-framework code to 100% of Kohana code, page by page.
The project uses php/js/css/html, MySQL and Apache.
The project is huge (with a guest and member areas).
Thank you.
I've never used Kohana, but I'm quite familiar in other PHP framework (Yii). My guess is that it is NOT possible. Or to put it in other way: everything is possible (except opening an umbrella in your ass! :), but taking time (and money) into account, it is not worth doing so.
Most professional frameworks are complete opposite to "pure PHP" code in extremely many areas. Code is separated most times (MVC = model-view-controller design pattern) and uses mostly framework classes or code. I would even risk to say that writing an application in some pro framework means using only 10-20% of pure PHP code and doing rest 80-90% purely on framework classes, extensions, controllers etc.
In other words: porting a "pure PHP" application into framework code would mean writing that application from scratch. I'm not sure, if you would be able to copy-paste more than 5-10% of your source code?

Need some advice on starting a New Life with MVC 2 and which Tools to use for RAD in MVC2?

I have finally decided to hop up on the train of MVC 2.
Now I have been doing a lot of reading lately and following is the architecture which I think will be good enough for most Business Web Applications.
Layered Architecture:-
Model (layer which communicates with Database). EF4
Repository (Layer which communicates with Model and includes all the queries)
Business Layer (Validations, Helper Functions, Calls to repository)
Controllers (Controls the flow of the application and is responsible for providing data to the view from the Business Layer.)
Views (UI)
Now I have decided to create a separate project for each layer (Just to respect the separation of concerns dilemma. Although I know it's not necessary but I think it makes the project look more professional :-)
I am using AutoMetaData t4 template for Validation. I also came across FluentValidation but cant find much on it. Which one should I go with?
Which View Engine to go for?
Razor View Engine Was Love at first sight. But it's still in beta and I think it won't be easy to find examples of it. Am I right?
Spark .. I can't find much on it either and don't want to get stuck somewhere in the middle crying for help when there is no one to listen...:-(
T4 templates auto generate views and I can customize them to generate the views the way I want? Will this be possible with razor and spark or do I have to create them manually?
Is there any way to Auto generate the repositories?
I would really appreciate it if I can see a project based on the architecture above.
Kindly to let me know if it's a good architecture to follow.
I have some confusion on the business layer like is it really necessary?
This is a very broad question. I decided to use Fluent NHibernate's autoconfig feature for a greenfield application, and was quite impressed. A lot of my colleagues use CakePHP, and it needed very little configuration to get it to generate a database schema compatible with the default conventions cake uses, which is great for us.
I highly suggest the book ASP.NET MVC2 in Action. This book does a good job at covering the ecosystem of libraries that are used in making a maintainable ASP.NET MVC application.
As for the choice of view engines, that can depend on your background. I personally prefer my view to look as much like the HTML as possible, so I would choose Spark. On the other hand if you are used to working with ASP.NET classic, the WebForms view engine may get you up and running fastest.
Kindly to let me know if its a good architecture to follow?
It's a fine start - the only thing I would suggest you add is a layer of abstraction between your Business Logic and Data Access (i.e: Dependency Inversion / Injection) - see this: An Introduction to Dependency Inversion.
i know its not necessary but i think it makes the project looks more professional :-)
Ha! Usually you'll find that a lot of "stuff" isn't necessary - right up until the moment when it is, at which point it's usually too late.
Re View Engines: I'm still a newbie to ASP.NET MVC myself and so aren't familiar with the view engines your talking about; if I were you I'd dream up some test scenarios and then try tackling them with each product so you can directly compare them. Often, you need to take things for a test drive to be more comfortable - although this might take time, but it's usually worth it.
Edit:
If i suggest this layer to my PM and give him the above two reasons then i don't think he will accept it
Firstly, PM's are not tech leads (usually); you have responsibility for the design of the solution - not the PM. This isn't uncommon, in my experience most of the time the PM isn't even aware they are encroaching on your turf that isn't theres. It's not that I'm a "political land grabber" but I just tend to think of "separation of concerns" and, well, I'm sure you understand.
As the designer / architect it's up to you to interpret requirements and (taking business priorities into account) come up with solution that provides the best 'platform' going forward.
(Regarding DI) My question is , is it really worth it?
If you put a gun to my head I would say yes, however the real world is a little more complex.
If you answer yes to any of these questions then its more likely using DI would be a good idea:
The system is non-trivial
The expected life of the system is more than (not sure what the right figure is here, there probably isn't one, so I'm going to put a stake in the ground at) 2 years.
The system and/or its requirements are fluid.
Splitting up the work (BL / DAL) into different teams would be advantageous to the project (perhaps you're part of a distributed team).
The system is intended for a market with a diverse technical landscape (e.g: not everyone will want to use MS SQL).
You want to perform quality testing (this would make it easier).
The system is large / complex, so splitting up functionality and putting it into other systems is a possibility.
You want to offer more than one way to store data (say a file based repository for free, and a database driven repository for a fee).
Business drivers / environment are volatile - what if they came to you and said "this is excellent but now we want to offer a cloud-based version, can you put it on Azure?"
Id also like to point out that whilst there's definitely a learning curve involved it's not that huge, and once you're up-to-speed you'll still be at least as fast as you are now; or at worst you;ll take a little longer but you'll be providing much more value (with relatively less effort).
In terms of how much effort is involved...
One-Off Tasks (beyond getting the team up to speed):
Writting a Provider Loader or picking DI Framework. Once you've done this it will be reusable in all your projects.
'New' Common Tasks (assuming you're following the approach taken in the article):
Defining interface (on paper) - this is something you'll be doing right now anyway, except that you might not realise it. Basically it's OO Design, but as it's going to be the formal interface between two or more packages you need to give it some thought (and yes you can still refactor it - but ideally the interface should be "stable" and not change a lot; if it does change it's better to 'add' than to 'remove or change' existing members).
Writting interface code. This is very fast (minutes not hours), as you're not writting any implementation; and when you go to implement you can use tools provided by your IDE to generate code-stubs based on the interface.
Things you do now that you'd do differently:
Instantiating a variable (in your BL classes) to hold the provider, probably via a factory. Writting this shouldn't take long (again, minutes not hours) and it's fairly simple code to copy, paste & refactor where required.
Writing the DAL code: should be the same as before.
Sometimes it is way more easy to learn patterns from code : Sharp Architecture is a concrete implementation of good practices in MVC, using DDD.

Migrating from one PHP framework to another

I'm working with a web company that's approaching a point where it will likely need re-think the product as a V2 - due to outgrowing some of its V1 foundations and principles that have been built into virtually everything, from the data model to the user interfaces. For various reasons, this evolution might involve a migration from CakePHP (with which the V1 has been built) to Symfony or Zend.
I would like to ask for some experienced views on how people might have managed a transition like this for a website that has significant traffic and generates revenue. I don't want to open up a discussion on the pro's & con's of different PHP frameworks, or why this migration might be needed. Rather, I would be very interested in hearing whether there are some practical alternatives to essentially building a V2 from scratch alongside the V1 for a couple of months - and locking up precious coding time for the duration of this intense period. An example of such an alternative might be migrating an app in parts over a longer period of time.
I'd be grateful for any views from people who might have managed or been involved in such transitions.
Thanks in advance.
Symfony makes it very easy to break out of the framework at almost every level in the process, making it easy to integrate with other frameworks. Here's how I would do this:
Set up and install Symfony.
Put the existing CakePHP project inside of Symfony as a plugin.
Set the plugin to have a catch-all route that takes the parameters and processes it as a Cake PHP request. Now you have all your CakePHP pages working in Symfony. This is probably the trickiest step and may involve resolving some autoloading or other collision issues.
You can now selectively migrate CakePHP models, controllers, and views.
A major benefit of this approach is that it lets you maintain an agile development process. You can port little bits of the website at a time all the way through and test them as you go.
If you will be moving to Zend, you can start using Zend Classes one-by-one to help you with basic tasks. You can very well use any model class with ZF. So only think that will need that 'big bang' action will be the controllers/views. In fact you can also integrate your existing views with ZF. But I think that'S an overkill and it will not last very long...
So - wrapped up
switch to zend classes for basic tasks like RSS generation, emails, validation, etc. That will help you in the next step.
make the big bang action and switch (m)VC to ZF, leave models
switch models to something more Zend-ish

Difficulties when learning Zend Framework 1.8

I am a newbie of Zend Framework.
I downloaded the Zend Framework and then followed the official quickstart tutorial to build a very simple registration form. But after that, I find very hard to learn different elements of Zend Framework.
Many tutorials mention frontController and registerAutoload() in the bootstrap file. However, it seems that I can't see it again in the code in version 1.8 (both in the official quickstart tutorial and Getting Started with Zend Framework 1.8). Many tutorials contain the old version of code and it seems very different in v1.8.
I start with writing registration form with password confirmation. I read the official document and find the custom validator for password confirmation. It just puts the class there and doesn't mention how I can use it. I don't know where I should put this file and I can't find any hints in Google. The "class not found" error always makes me sick (I've tried addPrefixElement, set_include_path but they don't work).
User registration, email activation, login, access control are very common tasks. But I don't even find a piece of sample code in v1.8 that I can run in my machine. I am very frustrated about Zend Framework.
Does anyone give me some advices?
I have also just started learning the zend framework. I also find alot of old tutorials that make learning confusing and hard,
but there are some resources that I find help in learning the zend framework:
http://www.zendcasts.com/ - they have tutorials on ZF1.8 already, like Bootstrapping using Zend_Application, etc.
Some useful blogs that might help:
http://weierophinney.net/matthew/
http://www.thomasweidner.com/flatpress/index.php
http://smartycode.com/zf/
http://codeutopia.net/blog/
Forums to ask your questions:
http://www.nabble.com/Zend-Framework-Community-f16154.html - alot of ZF developers seem to be here to answer your questions :) much more than the official Zend Forums below ...
http://forums.zend.com/viewforum.php?f=69
As to class not found, I think you didn't autoload?
http://framework.zend.com/manual/en/zend.loader.autoloader-resource.html
Parts of Zend Framework have changed slightly in the 1.8 release but everything should be backwards compatible so all code example written using the 1.* release series should still work with little or no modification. The main areas that are different are
Zend Loader (related to register_autoload) which now has several improvements related to performance and some slight differences in its API (with a PHP warning if you use the old way). I wouldn't worry about this too much as a beginner - just follow the tutorial or continue to use include/require statements until you become annoyed with adding them all the time!
Zend Application which basically allows you to create your set-up and initialisation code with less fuss. Again, you don't have to use it and you can happily write a manual bootstrap class to get you used to how the framework is put together.
With regards to getting started I would highly recommend getting your head around the Zend Controller component, particularly the front controller part and this diagram.
For authentication look at Zend Auth, for e-mail see Zend Mail, for access control see Zend Acl and for forms and validation see Zend Form, Zend Validate and Zend Filter. The form and validation components will explain about paths and adding your own custom validators and form elements.
The other area of importance is Zend Db which allows you to persist your data to a database. There is also Zend View which represents the view layer in the MVC stack. In my opinion these are the key components of a basic ZF application. From there you can explore the other components as and when you need them.
Don't forget that the Zend Framework is specifically designed to be loosely coupled and it is very easy to use a different component from another project for a particular task. Sometimes it is necessary to write your own components too. If there is a component you would prefer to use over the Zend component then go ahead and do so.
Honestly, the documentation is very good although it is hard to navigate for beginners. Once you get your head around the core components everything will become a lot clearer.
Also try following this tutorial. It will help explain a lot of the basics.
I recommend these video tutorials pu up by a guy called Alex, he keeps them up to date and releases new ones all the time,they are all relevant to ZF 1.8 and 1.9.
He has even a detailed video tutorial covering ACL, login forms etc. (my first steps with Zend were easier thanks to him!)
http://alex-tech-adventures.com/development/zend-framework.html?start=15
- his site is a bit comfusing but worth the time in figuring it out :)
Cheers
Roman
Some tips:
Here is a nice diagram of the Dispatch process
http://nethands.de/download/zenddispatch_en.pdf
It is much easier to understand ZF if you are experienced in OOP / OOP Design Patterns
When I first stumbled across ZF I had little knowledge of OOP. ZF prompted me to learn OOP which was a very good thing.
Distinguish between the 'magic' of ZF and the actual ZF Architecture
Although I have a good understanding of ZF Classes I still get confused when ZF adds its 'magic' to the mix.
When I say 'magic' I am referring to things like
the default objects loaded and used if none specified, and
url-controllername-filepath-filename inflections / naming conventions.
config settings-to-class-instantiation mappings
ZF is a bit like a crack-dealer in the sense that the 'Getting Started Tutorials' get you hooked straight away. They perform so much magic that it makes you think
.oO(Wow - how simple was that! This framework is cool!)
Then as soon as you start to try to do your own thing - the magic starts to get really confusing.
So - my tactic is to remove as much ZF magic as possible. If you have the option to specify a class to use, or a router to use, then specify it. Don't let Zend do it for you.
Then when something weird is happening you can find the bugs more easily.
Also, if you specify the locations of classes/ paths as (opposed to letting ZF magically inflect paths and find scripts), then you do not have to worry about questions of 'where to put this? , where to put that?' - you just put things where you want them to be and explicitly point ZF to them.
As you get more familiar with ZF you might then want to let it take over and do some magic for you. Only then can you really understand why that magic is convenient.
As Tim Wardle said in another answer - favour require statements over zend loader until you really need it.
If you are a PHP design house that churns out 10 website projects a week, then ZF Magic can be really useful. If you are designing your first ZF app - then 'reducing complexity' is a more important design goal than 're-usability'.
Browse the code
It might seem obvious but one of the best ways to learn about the ZF is to look at the code.
Again the ZF magic can get in the way - I often want to look at a method's arguments to discover what i need to pass in only to discover that it expects an ambiguous 'options array' (not exactly helpful). After a while, though, you start to notice the conventions used in how an 'option key' marries up to a getter/setter method. So, keep looking at the code and familiarising yourself with the 'ZF way'.
I 'ope that 'elps.
The Front Range PHP Users Group website has some presentations on Zend Framework which may be of use.
I have so much sympathy with you Billy. I am a newbie and the confusion between the old way and the new way is almost just too much to handle. Also see here for someone who points out some of the main differences:
http://crossfunctional.wordpress.com/2009/05/
All documentation, particularly Zend's documentation is absolutely horrible. It all assumes that you "know" where to put the snippets they are referring to and how they work together. If I already knew those things, I wouldn't need the documentation. No full example applications with authentication etc. that you can download and modify. I'm seriously regretting putting any time into trying to learning this framework. All examples that I can find are apparently for older versions. I followed one for authentication on youtube that was designed for 1.8 to the letter. It fails to work in 1.9.x. Can't get it to work for the life of me. Completely frustrated with Zend Framework!
Zend Framework has shifted from being a relatively accessible and simple system to a more complex entity. It has gone through a number of rapid developments over the past couple of years which have left a lot of older documentation around.
We have projects that are stuck on Version 1.7.x because the differences between that and the latest version are too great which makes the dev and testing time too expensive.
I like Zend Framework because it has so much depth to it but it is definitely a two edged sword for beginners.
I'd certainly recommend making use of the expertise of other users and search out some simple framework examples. ZF is highly adaptable but you need to try and work from the simplest case possible for your needs.
I think Matthew Weier o'Phinney, (search for 'Phly, boy, phly') is one of the more approachable members of the dev team and has loads of examples and ideas on his website.
Good luck!

What is scaffolding? Is it a term for a particular platform?

Scaffolding, what is it? Is it a Rails-only thing?
Scaffolding generally refers to a quickly set up skeleton for an app. It's not rails-only since other platforms have it as well. It's also not generally meant to be a "final" system; merely the first, smallest way to do it.
From Wikipedia:
Scaffolding is a meta-programming
method of building database-backed
software applications. It is a
technique supported by some
model-view-controller frameworks, in
which the programmer may write a
specification that describes how the
application database may be used. The
compiler uses this specification to
generate code that the application can
use to create, read, update and delete
database entries, effectively treating
the template as a "scaffold" on which
to build a more powerful application.
Just like a real scaffolding in a building construction site, scaffolding gives you some kind of a (fast, simplified, temporary) structure for your project, on which you can rely to build the real project.
It can be (and is today) used to describe many things - from abstracting DB layers, to web apps folder structures, and to generating and managing project dependencies .
It is not something that is specific to any language / technology, just like the term skeleton or boilerplate is platform agnostic.
It is just a term borrowed from real scaffolding (like mentioned above).
You build some fast, simplified, (sometimes external, sometimes temporary) structure that will help you to build the real, more complex, finalized structure under, above, inside or outside of that temporary structure .
.. And just like the real scaffolding, the scaffolding structure is meant to support the building process of the project, rather than the project itself (with some exceptions).
Scafolding is usually some type of code generation where you point it at a database, and the technology creates basic CRUD (create, read, update, delete) screens.
I believe that Wikipedia and some answers here provides a narrow and restricted view. Scaffolding is not just for CRUD operations on top of a database. Scaffolding has a broader objective to give you a skeleton app for any kind of technology.
Yeoman is a modern and useful tool for scaffolding. Using their own words:
The web's scaffolding tool for modern webapps
What's Yeoman?
Yeoman helps you to kickstart new projects, prescribing best practices
and tools to help you stay productive.
To do so, we provide a generator ecosystem. A generator is basically a
plugin that can be run with the yo command to scaffold complete
projects or useful parts.
Through our official Generators, we promote the "Yeoman workflow".
This workflow is a robust and opinionated client-side stack,
comprising tools and frameworks that can help developers quickly build
beautiful web applications. We take care of providing everything
needed to get started without any of the normal headaches associated
with a manual setup.
With a modular architecture that can scale out of the box, we leverage
the success and lessons learned from several open-source communities
to ensure the stack developers use is as intelligent as possible.
As firm believers in good documentation and well thought out build
processes, Yeoman includes support for linting, testing, minification
and much more, so developers can focus on solutions rather than
worrying about the little things.
That's it. Use scaffolding to create a quick-start application to work as an example or the foundation of your solution. It makes you productive faster them building things from scratch.
It is not a rails only term although I think it originated there (at least that is where I first heard it.)
Scaffolding is a framework that allows you to do basic CRUD operations against your database with little or no code. Generally, you then go through and add the code to manage the data the way you want replacing the scaffolding. It is generally only intended to get you up and running quickly.
No it is used in other technologies also such as ASP.NET MVC
it creates a basic layout from some predefined code which programmers uses in almost every project , Eg: for database data access it can make a crud method for create, read, update, delete operations
OR you might use it to create layout for your View/Html Code
Scaffolding is writing any piece of code that would not be part of the business logic but would help in unit testing and integration testing.
This is a software engineering term and not bound to any framework or programming language.
No, scaffolding is not the term for the specific platform, however many know this term in the context of Ruby on Rails or .NET
There are also plenty of tools that perform javascript scaffolding:
divjoy.com
flatlogic.com
scaffoldhub.com
yeoman.io
Those tools are also known as code-generators
Scaffolding is the term used when you don't want to create all parts of the structure such as models, views, etc. and want to generate them all in one go. A lot of frameworks use this technique, I studied about it while doing odoo but most of the references given were to ruby on rails :)