Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 132545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:16:46+00:00 2026-05-11T06:16:46+00:00

Please share your favorite application design / design patterns for use in PHP with

  • 0

Please share your favorite application design / design patterns for use in PHP with me. Some things I’d like to know:

  • How your folders are designed
  • How you use object oritentation in your PHP applications
  • Do you have a standard way of dealing with CRUD, pagination, or any other common tasks?
  • How do you avoid using repetitive code? What’s your approach to libraries/sharing common code, etc?
  • What are ways in which you can make your code more elegant?

You don’t have to answer all of these, answering any or a few of these will be helpful.

The reason I’m asking this,is because I’m very tired of writing repetitive, ugly code in PHP and I want to make a small framework for my freelancing projects which will make programming easier and let me focus on the challenging/business tasks rather than form validation, pagination, and the other mundane activities which make up 80% of programming work in PHP

All opinions appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:16:47+00:00Added an answer on May 11, 2026 at 6:16 am

    I might get voted down for this, but if you really do want to write your own framework, I say go for it because you will learn a lot from the experience. The other frameworks mentioned here are great and tested and you wouldn’t be making a bad decision using them, but it’s your choice.

    Before starting to write your framework, look at the other frameworks (at their syntax, directory structure, naming schema, design patterns, etc) and try to figure out why they did what they did and what, if anything, you would do differently. Try out a few tutorials and play with their code, make a few sample apps. If, after doing that, you don’t like using them, then go ahead and start planning your framework, keeping what worked and improving what didn’t.

    If you do decide to roll your own, here are a few things I would recommend from my own experience:

    • Make Security Your Top Priority – If you write a data access layer, use bound parameters. If you write a form class, guard against CSRF and XSS. Catch your exceptions and handle your errors. Make sure that your PHP environment is secure. Don’t try coming up with your own encryption algorithm. If you don’t concentrate on security, it’s not worth writing your own framework.
    • Comment Your Code – You will need comments to help you remember how your code works after a while. I usually find that docblock comments are more than enough. Beyond that, comment why you did something, not what you did. If you need to explain what, you may want to refactor.
    • Single Responsibility Classes and Methods – Most of your classes and methods should do one thing and only one thing. Especially watch out for this with the database – Your pagination class shouldn’t rely on your data access object, nor should almost any other (low-level) class.
    • Unit Test – If each of your methods does only one thing, it should be far easier to test them and it will result in better code. Write the test first, then the code to pass the test. This will also give you greater freedom to refactor later on without breaking something.
    • Abstract Similar Classes – If you have more than one class that does similar things, create a parent class that uses the similarities between the classes and extend it.
    • Delegate and Modularize – If you’re writing a validation system (and chances are you probably would), don’t include each validator as a method in some super validation class. Separate them into individual classes and call them as needed. This can be applied in many areas: filters, languages, algorithms, validators, and so on.
    • Protect and Privatize – In most cases, it’s better to use getter and setter methods rather than allowing direct access to class variables.
    • Consistent API – If you have a render() method and a draw() method that do the same things in different classes, pick one and go with it across all classes. Keep the order of the parameters the same for methods that use the same parameters. A consistent API is an easier API.
    • Remember Autoloading – The class names can get a little clunky and long, but the way Zend names the classes and organizes the directories makes autoloading a lot easier. Update: As of PHP 5.3, you should begin using namespaces.
    • Never echo or print anything – Give it as a return value and let the user decide if it should be echoed. A lot of times you’ll use the return value as a parameter for another method.
    • Don’t Try to Solve the World’s Problems – Solve your own first. If you don’t need a feature right now, like a class for localizing numbers or dates or currency, don’t write it. Wait until you need it.
    • Don’t Preoptimize – Build a few simple applications with your framework before fine tuning it. Otherwise, you can spend a lot of time on nothing productive.
    • Use Source Control – If you spend countless hours creating a masterpiece, don’t risk it getting lost.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 114k
  • Answers 114k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Windows: Safari 4.0 (530.17): Fail That being the case, .animate()… May 11, 2026 at 10:13 pm
  • Editorial Team
    Editorial Team added an answer Two's complement is a clever way of storing integers so… May 11, 2026 at 10:13 pm
  • Editorial Team
    Editorial Team added an answer Ok looks like I can answer this myself actually: I… May 11, 2026 at 10:13 pm

Related Questions

Please can anyone recommend a quick checklist / best practice guide to help us
How exactly can one implement a Log off function when using ASP.NET Forms Authentication
When and why would somebody do the following: doSomething( (MyClass) null ); Have you
I am looking to use this concept in one of my upcoming project. More

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.