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

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?

Related

Silex vs SLIM PHP Framework

We have narrow down our search between Silex and Slim PHP frameworks for routing our REST APIs on our Apache/PHP/MySQL Server.
Both seem to have good reviews. Silex has probably a bigger community because it came from Symfony. But the documentation seems to be better in Slim.
What do you guys suggests? Any real world experience from production environments?
Sathish
I had the same choice to make, and I choose Silex, here is why :
Silex seems to have a bigger community than Slim, maybe it's just my point of view
It's based on Symfony components, so with a bit of reflection, you can use tips and workarounds which work for Symfony and apply them to Silex.
As it's based on Symfony it has a better integration with other bundle (for example Twig, which is for me necessary)
This Symfony base also garanty that it will be more "Long Term Support" that Slim, which is independent.
To conclude, the main argument is that is based on Symfony which has many advantage.
The Symfony Debug tools are the best thing on earth !!
Now I have two sites made with Twig and I'm really happy !
You can also see that, it's a technical comparison of these both frameworks :
https://michalzuber.wordpress.com/2015/04/02/silex-vs-slim-php-microframework-comparison/
Slim 3 is very light weight and well suited to APIs.
You can optionally inject a container (Pimple by default but any Container-Interop will work) when constructing your Slim app. The Silex app extends Pimple so is a container.
Require slim/twig-view if you need Twig.
Slim's Request and Response support PSR-7 HTTP message implementation.
On January 12th 2018, Fabien Potencier, main author of this micro-framework, wrote that Sensiolabs stops supporting Silex.
https://symfony.com/blog/the-end-of-silex
Quote from Silex official site:
Silex is in maintenance mode. Ends of life is set to June 2018. Use Symfony 4 instead. Read more on Symfony's blog.
Slim is better if you want to create apis as its light and fast. Hence slim provides you the DI and routes it is much more flexible to use your own libraries or plugins from laravel or symfony or any third party.
For example you can use sentinel from laravel for auth
TL;DR Choose Slim 4. "At its core, Slim is a dispatcher that receives an HTTP request, invokes an appropriate callback routine, and returns an HTTP response. That’s it.". That should be it.
Late to the party but nonetheless here's my 2 cents(!) on the topic especially for future-googlers about this topic (even though Silex has reached end of life); I'd go for Slim. Which I already did on my previous 2 projects and it never let me down. Before the "here's why" part I'd like to share my background in a nutshell; I've worked with CakePHP and Laravel (especially >=5.4, <5.8) (and also with Lumen) years and years ago, right before I introduced myself with Node.js. Since then almost all my work runs on Node.js in the cloud. Now there's Golang on the table... but that's another story. Due to the requirements (or I should say constraints) of the aforementioned 2 projects, I have to write PHP. Since all those years past with Node.js I suddenly realized that I've forgotten about PHP almost completely. But there were 2 things I remember crystal clear; I've suffered. A lot. Because of those frameworks.
Don't get me wrong former is the eldest one and the latter is the hipster of the pack, I respect them, their authors and their community. Everything has a reason to exist. But one is behemoth and the other one is magical (both not in a good way - I mean did you ever try to debug the Laravel with those facades and static methods and stuff?). OK I hear you, they are frameworks and they should do things for you (have you heard of Hollywood Principle), not everything for you. What this does mean to me is that they always whispering to your ear "our way or highway" (sometimes even yells). "Surely you can do this (say push a job to a queue, query your database, send email, etc.) but first do this, and then that" (maybe couple of more steps but this is not that bad). The bad thing about this is (not accusing anyone) I don't know what do they mean to the framework. They must do something meaningful, obviously though, I don't know what it is. Should I know? Yes, of course. I'm writing this application with that framework for God sake, I should know what it does. Version X was easy to grasp, but what about version Y, Z, T... Have you seen the version dropdown on the Laravel's documentation site? I took those steps because I've been told so. Again that's OK, fair is fair, those steps makes me achieve something far greater. But gradually I'm in their (respective authors') control. After that, even small change takes lots of searches on SO, GitHub issues, Google... Sometimes ends up with a success and most of the times don't. Either way the war against the framework must be declared.
In my point of view this is not how an open-source framework should be. I am vendor locked-in in some sense. Maybe I want to adhere PSR (not that because I'm an advisor recommendation freak, because PHP-FIG is a well-known group with standards almost for every aspect of the language - this is important; for the language, not for any framework). Let me ask you something; do you use Composer? If so why? Because it's standard (I'm not sure if it is)? Because everyone uses it? Because the needed package of yours recommends this way of installing? Actually the answer doesn't all that matter, at the end of the day you use it. And you can use it practically for every PHP framework/project. The Composer requires you to have PHP installed on the system at bare-minimum and coincidentally it's the only requirement. This is freedom, and I want that. I want to pick and choose a router or a container for my taste. Today this package, later something else.
Slim gave me that freedom, especially on version 4. It's community is small, it's foreseeable; it does so much less than the other, full-blown frameworks. Actually it's a micro-framework (although I wrote an MVC application and REST API server with it). Other packages' communities are what matters right now. You need a container, composer require php-di/php-di. Now think about it's community, since "your" application (hence the framework) is a part of it. You have a problem? Ask for help specifically for that package. Maybe someone using another framework (or someone using no framework at all - if there's any left nowadays) might help you with your problem. So you've gone framework-agnostic thanks to your setup. Don't you like PHP DI, well find yourself another PSR-11 compliant package. Same applies for almost every part of Slim - except the router (Nikic's FastRouter should ring a bell), although it's already a foundation for other routers I see so far.
Before I finish I should say that too, Lumen and Silex has big brothers. I've been through a handful of frustration moments with Lumen; when I say "I can't do [fill here with a not-so-common problem] with Lumen version X.Y" they say "Use Laravel instead, it is really easy to upgrade". It should be for God sake! They share the same blood. I wasn't ask for that. If I were like to use Laravel I would choose it in the beginning and not use the Lumen in the first place. There were some reasons I did choose Lumen, like there were some reasons the author write it too (which I don't know why, but still...). Lumen should be a lighter weight, micro-framework alternative to Laravel, not a stepping stone.
Choosing Slim has it's disadvantages too but I think it's about the perception. I want to know what's happening on my application given the circumstances. Isn't reasoning about actually that? Even if I'm going to this rocky road at least I know at the end my application will do exactly as I commanded, nothing more nothing less.
Thank you for your time and please excuse me for formatting.
The fact that Silex didn't support PSR-7 (at the time of writing this) a huge let down. It has so many good point already mentioned above. There is a plugin/extension that let you do that, however I don't see the point in adding this overhead when you are looking for a lightweight framework

Play 2 Framework code generation tool or Yii/Cakephp frameworks?

I'm trying to get started with a couple of web applications. However, choosing a framework to work with can be overwhelming!
I've worked with Java in the past, and since I do C# .NET at work, I don't mind learning and extending my Java knowledge. Now, the only framework that seems to work without jsp and other applet things that I've never understood is Play 2 Framework. I downloaded this framework, put the executable file in my path, and it seems that it would work for me. However, I came across CakePHP and Yii frameworks (I'm sure there is more) and notice there is a code generation tool that gets the database and automatically generates the models for you + the CRUD and such. Geez that is a save of time.
I went and googled my question and got that this is also possible in Play Framework (bummer only found the module for 1.x framework.)
How to quickly generate models in play framework 1.2?
http://www.playframework.org/modules/db
So, my question is...
Is there a module that would easily let you do this work in Java Play 2.0 Framework as in the mentioned PHP frameworks?
If no, would it be worthy (any advantages) to stick to the Java Framework?
If no, what php framework or even python (but Ruby) framework you consider has the best tools like this auto completion feature? I don't mean learning a new language, I will have to anyways. But rather to learn a language I can do things other than web development (for Ruby I know you can do more stuff but it might be just a waste of time to learn that other language. However, learning Python, Java, would open up app and phone development as well)
Don't mean to open a debate, please be concise (not like me) in your answer. Thanks!
From personal experience, there's several difference in both frameworks, particularly the way models are handled in cake vs yii.
In cakephp you cannot use composite primary key, this is the main deal-breaker for me. Composite primary key is supported in Yii.
Cakephp enforces convention, while yii favors convention, you are not forced to follow a certain standard.
Out of the box performance, I think yii has the advantage, but as with performance tuning, with proper cache configuration, and as long as you are careful in using the ActiveRecord patterns, they are not that much apart
As a side note, I have lead web app implementation with both CakePHP and Yii, the feedback that I got from the team was that the less experienced team preferes CakePHP, while Yii is preferred by the more experienced team. Make of that what you will.
Well it can turn out to be a very long debate. Each has its own life. So far from Experience I have found Yii to be most promissing than everyone. For me it matters who gives more work in less time. Cake is a bit heavy but Yii is light weight framework. I am from .Net Background but it took mew few weeks to get going with Yii

Framework for enterprise application

I have been developing a plain JSP/Servlet web application, which focuses mainly in collecting large sets of data through JSPs, processing them and finally commiting them to a MySQL database. Imagine something like a declaration of assets for a pretty big number of people.
While it works pretty good now, the code is really jumbled up and since I now have the time, I am thinking of completely redesigning the whole application in a more sophisticated and reusable way. My main problem is that forms are built mainly through jQuery (my form_build.js and form_validate.js files span over 600 lines each at the moment), and the back-end java code is jumbled up since there is massive use of name[counter] input fields.
I.e. The user can add 5 assets in the form, where he has to submit something like 30 fields of information on each one. The form sends them in the form of attribute[asset_counter].
If I managed to make myself clear, I have been looking into the Google web toolkit - which I had no idea of before - and from what I gather mastering it will take some time for me. Is it worth the trouble, or is it aimed at something completely different? And is there a framework or technique that can handle efficiently what I need?
Frankly, I am a senior java developer and I used a lot of jsp/jsf web applications accompanied by EJB, webservice, simple spring web apps, and I recently came up to use GWT.
It's a very nice platform, it has the following advantages:
All the code is compiled to html/JS which is better in terms speed
and browser understanding agilty
It uses built in JSON xml transer (nice approach)
It use built in AJAX (nice approach)
It use it's own cleint server platform (no need to use other
libraries for each one)
It will adopt to any browser (strong competetor)
drowbacks:
Sometimes it takes time to load in the browser (specially when using
FlexTables)
I advise you to use it!
GWT is a very powerful toolkit, and from what I understand it might help you to better organize you client side code. But you also have to consider some high-level JS framework like backbone.js+require.js or Google Closure. Time spent to learn this frameworks this bascially the same as for GWT, the choice basically depends on what your team prefer, JS or Java. In most cases when logic on client side gets very complicated, I will choose GWT.

Zend Framework - Ruby on Rails has a screencast showing how to code a blog in 15 minutes. Does ZF have a similar screencast?

Ruby on Rails has a screencast presentation they use to promote their framework that shows how to code a basic weblog system in 15 minutes with RoR. Does the Zend PHP Framework have a similar screencast/presentation/whatever demonstrating something similar? It doesn't have to be a blog specifically, but I would definitely like to find a presentation that shows some rapid application development using ZF.
Where I'm coming from: I have been programming on and off for years now. I started out with QBASIC waaaaay back in the day making little programs (text adventure games, screensavers, simple little things). I then moved to C++ but never really did anything too impressive with it. Since then (probably 5 years or so now) I have started to use C# for my desktop development and PHP for my web development. I've made some pretty cool tools here and there, but am certainly not a professional programmer by any stretch of the term as it has always simply been a hobby of mine.
Right now I have two major web applications that I will start work on shortly. (Like tomorrow, or later tonight ideally.. :) ) Both will be database-driven apps that will require user registration, the ability to manipulate data that is specific to their account (their posts, listings, user account details, etc), amongst other things.
Currently I am evaluating different frameworks to help me develop these web apps more quickly. I've been looking at, and have heard good things about Ruby on Rails. Hulu and YellowPages.com using it is an obvious endorsement - Of course, I have heard about the scalability issues that it potentially has; but that shouldn't be an issue with what I am working on. I don't expect millions of users per day for either project.
I am also seriously looking at the Zend Framework for my needs because I already have some experience with PHP. Ideally I would like to find a ZF screencast that shows an app being written quickly so that I have a roughly equal comparison between the two options I am exploring and can see first-hand how things get done in both.
That said - I am not opposed to considering frameworks other than RoR or ZF. The only research I've done on the subject has been over the past couple of days so I am quite certain that there are other excellent options out there that I've not even looked at - or heard of. Of course, it'd be awesome if there is a rapid app dev presentation that I can watch for whatever else is suggested.
So - Suggestions? Links to good screencasts that show rapid application development in other frameworks? Are there other PHP frameworks that I should be considering? (Ones that are easy to deploy would be ideal, so I don't have to purchase a dedicated server that I have full control over. I'd like to keep my hosting costs down assuming that it's reasonable)
Thanks in advance!
-Sootah
You can checkout ZendCasts.com
However, when deciding between ZF and RoR, you should be aware that they are very different from each other. RoR is a full stack with integrated ORM built on AR and a rather rigid structure. It's powerful and there is lots of magic inside and I'd say it's RAD capabilities are above ZF due to rake being more powerful than Zend_Tool
ZF, on the other hand, is first and foremost a loosely coupled component library with a use-at-will architecture for maximum flexibility. You can use it's components together, but you don't have to. While it does feature convention over configuration, ZF doesn't take you by the hand too much. It expects you know how to walk. Also ZF has no full fledged ORM and no AR, but you can very much integrate Doctrine or Propel or whatever library you like to use.
You often hear folks new to ZF complain about it is hard to get into it, simply because they expect ZF to work like RoR or Symfony or Cake, e.g. a full stack framework
EDIT:
Cake aims to be a port of RoR to PHP. It is built around ActiveRecord. Like CI < v2, it is backwards compatible with PHP4, which means it doesn't fully utilize the OOP capabilities you get in PHP5. I'd say both are easier to get in than ZF though.
This is a common question on SO.
I posted some valuable links in my response to this post
If you Google for such tutorials, look for Zend Application or Zend Tool, not ZF.
The difference between the other frameworks and Zend Framework is that Zend Framework is rather a general purpose framework, not application framework (not only for MVC, HTTP). E.g. Google uses ZF to provide access to their services.
You may easily use Symfony or CodeIgnitier with Zend Framework together.
BTW, To be precise, tutorials you ask are not blogs, but just a simple CRUD controllers. You may use Wordpress to create blog in 15 minutes, (then customize it) but not a PHP Framework.

Do you need a framework to write Ruby or Python code for the web?

Every time I see Ruby or Python discussed in the context of web development, it's always with a framework (Rails for Ruby, Django for Python). Are these frameworks necessary? If not, is there a reason why these languages are often used within a framework, while Perl and PHP are not?
I can only speak towards Ruby - but, no, you don't need a framework to run Ruby based pages on the web. You do need a ruby enabled server, such as Apache running eruby/erb. But, once you do, you can create .rhtml files just like RoR, where it processes the inline ruby code.
The short answer is no, they are not necessary. In ruby you have .erb templates that can be used in a similar way as you use PHP pages. You can write a site in ruby or Python using several technologies (Rails-like frameworks, Templates or even talking directly with the HTTP library and building the page CGI-style).
Web frameworks like Python's Django or Ruby's Rails (there are many) just raise the level of abstraction from the PHP's or ASP's, and automate several process (like login, database interaction, REST API's) which is always a good thing.
"Need" is a strong word. You can certainly write Python without one, but I wouldn't want to.
Python wasn't designed (like PHP was, for example) as a direct web scripting language, so common web-ish things like connecting to databases isn't native, and frameworks are handy.
EDIT: mod_python exists for Apache, so if you're merely looking to write some scripts, then Python doesn't need a framework. If you want to build an entire site, I'd recommend using one.
From a Pythonic point of view, you'd absolutely want to use one of the frameworks. Yes, it might be possible to write a web app without them, but it's not going to be pretty. Here's a few things you'll (probably) end up writing from scratch:
Templating: unless you're writing a really really quick hack, you don't want to be generating all of your HTML within your Python code -- this is a really poor design that becomes a maintainability nightmare.
URL Processing: splitting a URL and identifying which code to run isn't a trivial task. Django (for example) provides a fantastic mechanism to map from a set of regular expressions to a set of view functions.
Authentication: rolling your own login/logout/session management code is a pain, especially when there's already pre-written (and tested) code available
Error handling: frameworks already have a good mechanism in place to a) help you debug your app, and b) help redirect to proper 404 and 500 pages.
To add to this, all of the framework libraries are all heavily tested (and fire tested). Additionally, there are communities of people who are developing using the same code base, so if you have any questions, you can probably find help.
In summary, you don't have to, but unless your project is "a new web framework", you're probably better off using one of the existing ones instead.
Framework? Heck, you don't even need a web server if you're using Python, you can make one in around three lines of code.
As to the why:
The most plausible thing I can think of is that Perl and PHP were developed before the notion of using frameworks for web apps became popular. Hence, the "old" way of doing things has stuck around in those cultures. Ruby and Python became popular after frameworks became popular, hence they developed together. If your language has a good framework (or more than one) that's well supported by the community, there's not much reason to try to write a Web App without one.
A framework isn't necessary per se, but it can certainly speed development and help you write "better" code. In PHP, there are definitely frameworks that get used like CakePHP, and in Perl there are many as well like Mason and Catalyst.
The frameworks aren't necessary. However, a lot of developers think frameworks ease development by automating a lot of things. For example, Django will create a production-ready backend for you based on your database structure. It also has lets you incorporate various plugins if you choose. I don't know too much about Rails or Perl frameworks, but PHP frameworks such as Zend, Symfony, Code Igniter, CakePHP, etc are used widely.
Where I work at we rolled our own PHP framework.
Are these frameworks necessary?
No. They, like any 'framework', are simply for speeding up development time and making the programmer's job easier.
If not, is there a reason why these languages are often used within a framework, while Perl and PHP are not?
PHP and Perl were popular languages for building web sites well before the idea of using frameworks was. Frameworks like Rails are what gave Ruby it's following. I'm not sure that Python or Ruby were that common as web languages before they were backed by frameworks.
These days, even PHP/Perl web developement should be backed by a framework (of which there are now many).
By no means are those development frameworks required. But as with most development environments, your productivity will increase exponentially if you have a supported framework to reference and build your applications on. It also decreases the training needed to bring others up to speed on your applications if they already have a core understanding of the framework that you use.
For python, the answer is No you don't have to. You can write python directly behind your web server very easily, take a look at mod_python for how to do it.
A lot of people like frameworks because they supply a lot of the boilerplate code in a reliable form so you don't have to write it yourself. But, like any code project, you should choose the tools and frameworks on their merit for your problem.
You can certainly write CGI scripts in either language and do things "raw".
The frameworks (ideally) save the trouble of writing a pile of code for things that other people have already handled (session handling, etc.).
The decision probably comes down to what you need to do. If the framework has the features you need, why not use it. If the framework is going to require extensive modifications, it might be easier to roll your own stuff. Or check out a different framework.
The python library has numerous modules for doing cgi, parsing html, cookies, WSGI, etc:
http://docs.python.org/library/index.html
PHP has a lot of frameworks. Probably more then most. In Ruby most use Rails so thats what you hear, and Django for Python is mentioned more then not.
But with PHP you have many to choose from.
List of web application frameworks
Any language that can "print" can be used to generate web pages, but frameworks handle a lot of the HTML generation for you. They let you concentrate more on the content and less on the details of coding the raw HTML.