Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Going from a framework to no-framework [closed]

I've been developing in PHP for about 8 years as a hobby. In 2009, I picked up codeigniter and since then I've not managed to get a single project developed.

I find it slows me down trying to work out how to modify it to work the way I want, when if I was working in pure PHP, I'd know, or I'd be able to quickly find a snippet for.

I've tried CodeIgniter, Kohana and Symfony. I love the ease of use (and I've also started using doctrine as an ORM which massively sped up my database work), but I find projects are taking me 3-4 times the amount of time it took in pure PHP. I get bored and frustrated when I can't find a solution to a problem I've previously solved in pure PHP.

Has anyone gone back from using frameworks to a no-framework approach. Is there anything like a basic security framework (prevent XSS, filter posted data, provide a cleaning function for use with databases)? I think something like that would benefit me much more than a full scale framework. I think learning to work with frameworks has taught me a lot, but I'd be happier working with my own code.

like image 940
Alex C Avatar asked Sep 07 '10 01:09

Alex C


People also ask

Can you build backend without framework?

So, can you build rich web apps without using frameworks? The short answer is yes. There are plenty of websites out there that are built without using a framework; GitHub and YouTube are probably the most popular ones. The long answer might be a little more complicated than you think.

How do I make a single page application without framework?

Creating the Web Server We'll be using Express for our web server, so lets start by installing the dependencies and creating our directory structure. Next, we can create a server. js file and include the following. Navigating to http://localhost:3000 should now display your HTML file.

Can we create web application without framework?

Yes, it is entirely possible to write any web application without framework. Keep in mind that frameworks are also written in their respective programming languages - therefore, you can achieve same results without one, but it will be more time-consuming and will need more work to "reinvent the wheel".

Is it important to use a framework?

Frameworks are useful because IT processes can be large and complex. Without a consistent set of operating principles, records and governance practices, service delivery can become haphazard and inconsistent.


1 Answers

Current versions of PHP5 include much of the security framework you're looking for as part of the standard library.

  • Use filter_input_array to declaratively sanitize stuff coming in from the outside.
  • Access your database via PDO with parameterized SQL to prevent SQL injection attacks.
  • Use the following PHP settings to make your site more resistant to session fixation and cookie theft:
    • session.use_only_cookies (Prevents your session token from leaking into the URL)
    • session.cookie_httponly or the httponly attribute to session_set_cookie_params() (Protects against scripts reading the session cookie in compatible browsers)
    • More suggestions and PHP example code available on Wikipedia.
    • You can also use the httponly attribute with setcookie().
  • Nothing fancier than basic templating and header-setting is required for new HTTP and HTML5 features:
    • HTTP Strict Transport Security (Helps protect against WiFi exploits.)
    • X-Frame-Options (Restrict embedding of your pages. Good against phishing.)
    • HTML5 IFrame Sandbox Attribute (Sandbox 3rd-party ads/badges/videos. Already in WebKit. Likely to be at least partially implemented in Firefox 11.)
    • Content Security Policy (Firefox 4's new security framework, complimentary to the sandbox attribute. Now also being implemented in Chrome.)

If you're accepting HTML as input, I recommend grabbing HTML Purifier and calling it via a FILTER_CALLBACK line in your filter_input_array setup. Its whitelist-based approach to input security makes a great (and very powerful) first line of defense against XSS.

As far as I can tell, PHP doesn't come with a mechanism for protecting against cross-site request forgery, but I'm sure Google can help you with that one. The OWASP Security Cheatsheets include a section on it if you want to implement your own protection.

Out of curiosity, I decided to also start looking at standalone components and here's what I've found so far:

Templating:

  • PHP Template Inheritance (Regular PHP plus template inheritance)
  • TWIG (Django/Jinja2/Liquid-style syntax including autoescape and sandboxing. Compiles to cached PHP for speed.)
  • Dwoo (A faster, more featureful, PHP5-ish successor to Smarty. Includes a compatibility system for existing Smarty templates.)

Stuff I still haven't looked into properly:

  • Route dispatching (Only found RouteMap and Net_URL_Mapper so far. Thanks, cweiske.)
  • ORM (Just in case bare PDO isn't your thing)
like image 72
17 revs Avatar answered Oct 07 '22 15:10

17 revs