开发者

What are the relative advantages of various Python/PHP web frameworks (particularly for my project)?

开发者 https://www.devze.com 2023-03-24 22:00 出处:网络
I\'m deciding on a web framework for an upcoming project, and I\'d appreciate any advice. We\'ve decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) fo

I'm deciding on a web framework for an upcoming project, and I'd appreciate any advice. We've decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) for our server-side logic. I'm especially interested in web2py because of its jQuery integration.

About our project

  • Our pro开发者_StackOverflow中文版ject is to develop a security console for a complex cybersecurity system operating within an organization's internal network.
  • This console will be largely server-driven, as messages come in from the network and must be pushed by the server to the user.
  • The user will also be able to initiate security actions, the implementation for which will likely be in C++.
  • The interface we've planned will be relatively rich, and I want to leverage jQuery's power as much as possible.
  • We have some control over the browser environment we'll be running in (e.g., we don't have to worry about clients with JavaScript disabled).
  • Our site is likely to have only a few, long-lived client connections.
  • We are looking for software components with permissive licenses, though we're using some copyleft components (I see that web2py is LGPL while Django is BSD, so +1 to Django)
  • We have about a month to create a functional demo of our system, of which this interface is a small (but visible) part.

About us

We are two developers with about 5 years of programming experience, but little web development experience. I have several years of Python experience and a summers' worth of experience messing around with PHP. My coworker has some Python experience and has never touched PHP. I used Django once back in 2008, and was frustrated by the file and code structure, which I found highly unintuitive. Perhaps this structure is inherent to the MVC model (I've had similar experiences with Django and CakePHP since), and I just need to bite the bullet and memorize it.

My Question

Given the information above, what are the relative advantages of the various Python/PHP web frameworks for our project? As mentioned above, I'm especially interested in web2py because of its jQuery integration, though Django's dominance is (once again) hard to ignore.

Thank you very much for your time!


Before deciding on a framework, you should first decide if you want to commit to a language you are unfamiliar with.

You said you've both got minimal PHP experience, so you have to weigh up the advantages here; Will the pros for going PHP (if any) out weigh the amount of time the developers will need to spend to retrain? (Although depending on your background experience, PHP should be very easy to pick up.)

If you frame it like that, PHP would have to have a pretty convincing offering to give you. From what I'm seeing, specifically Django vs web2py, they both seem very close in functionality - which is good, but doesn't provide the "you must use x!" scenario you may be after.

However, If you will be bringing more people in later and feel finding people to work with web2py will be difficult, it may tip it to PHP. You said your self, Django's popularity (and BSD license) is hard to ignore, and it should make it easier to find people for later expansion.

If it were me, in your shoes, I would go with web2py. Assuming the development team will continue to be Python focused for the foreseeable future.


Python vs PHP: Python

With python, you can always write wrappers for C code so you won't have to mess with starting other processes and passing args to them. That might be useful for your security functions.

Web2py will allow you to easily write a webservice for this too, to more easily integrate the C portions with the web-site infrastructure.

If you already prefer python, I would go with that. If you need to bring on web-developers later that are trained in PHP, teach them Python. It won't take long, and I'm sure they'll appreciate it in the long run. Plus, moving from a PHP MVC framework to web2py or even django would make things easier. I've used CodeIgniter for PHP and find that web2py was so much simpler and easy to understand.

Also as for the directory structure, django is not actually true MVC -- it's MTV (model, template, view).

I find web2py's organization a little more straight-forward. But yes, either way it can seem strange at first. I would say YES, you should bite the bullet and use MVC.

In web2py, the "view" is html markup with the ability to write raw python code. The controller extracts data from the model (database), attaches any needed files (css/js etc) and the model of course simply defines the structure of the data and allows you to access it in an OO way.

Lastly, I wouldn't tip my hat in favor of web2py just because of jQuery integration. It does use it, and a some of the built-in framework stuff (like response.flash/session.flash, the LOAD function that loads a page or data from another controller) rely on jQuery, but using it in another framework only means you have to write an include statement (e.g. ).

But, the way it allows/forces you to focus on development is what takes the cake for me.


I've been using Django as part of my work for a couple years now and truly enjoy it when I can make it work. Unfortunately, and maybe it's just me, but I end up spending hours working on configuration every time I start a new server, or try to make it work in a development IDE.

It's relatively simple to start a new project and start coding. But there are all sorts of little catches that keep things from working if you deviate from the norm. Things like if you want your django project to serve from a subdirectory like example.com/django. The information is out there to make it work. But it's hard to find.

I can't tell you if web2py has those same problems or not. I only just learned about it from your question. It does look slick and simple though. I can tell you that after the hassles of getting the applications to serve properly from whatever server configuration I'm using, django is way more fun to program with than plain php. PHP frameworks may differ.


From my understanding the project not usual web application, you must need event driven program, web server in python.

Django won't help you here.You should look into Flask, Flask has inbuilt console too.http://werkzeug.pocoo.org/, you might need to use twisted, gevent,Flask jquery.


I would recommend asking about web2py on its mailing list -- you'll get lots of help and advice there. Regarding the LGPL license, note that it only applies to the framework, not your application -- you can license your application however you like, including closed source/commercial.

It sounds like you'll need some server push functionality, but if you'll really only need a few long-lived connections at a time, you might not need to bother with solutions like Twisted or gevent. If necessary, though, web2py does include this (requires Tornado, and works using WebSockets, though can be adapted to use other methods).

0

精彩评论

暂无评论...
验证码 换一张
取 消