What is a good starting point for small scale PHP development and would a framework be overkill?

I’m a web development intern working on a small PHP application (just a few pages with a little database access) which has fast become a couple of very non-DRY, non-OO, individual scripts.

A framework seems like overkill (maybe not?) but I was wondering what some best practices for code / folder structure and general solo, small-scale PHP development. What is your starting point for a small application such as this?

5

The thing about “small” projects is they rarely stay small. If they’re successful they grow. Otherwise they die. What happens is you add “just one more little thing” until eventually you have implemented a framework anyway, and it’s usually poorly designed because it was never intended to grow.

Even if you are convinced this time is different and your application won’t grow, there are so many things you get for free with a framework that I have a hard time seeing why anyone would forgo it. You get themes, user authentication and roles, administration pages, tested modules, security fixes, and more, all of better quality than an individual developer starting from scratch could produce.

Yes, there’s a learning curve associated with any framework, which is why people think they’re saving time by starting from scratch. That notion is very short-sighted. It’s ridiculous to assume that learning a heavily used and tested software application is harder than implementing one of your own from scratch. They have already encountered and solved hundreds of problems that you aren’t even yet aware exist.

Did you try using thinga like Silex, micro-framework from Sensio Labs?

There are number of other practices on code organization, and framework usage that you may find helpful:

  • Ten PHP Best Practices Tips that will get you a job
  • 63+ best practice to optimize PHP code performances

Well my advice for you is to use MVC and a PHP framework.

This will let you focus more on developing the application itself rather than the basic setting up of the project structure.

I use Zend framework and it’s great. The only drawback is its steep learning curve and awkward documentation. However, it has the biggest library of classes I have ever seen.

If you feel intimidated by the complexity of Zend framework then you can try CodeIgniter which has the best documentation out there in addition to many video tutorials. These tutorials got me to understand MVC in action.

When you get comfortable with it maybe you can move to a more full stack framework such as Symfony or CakePHP.

Note:

Some will argue that frameworks such as Zend, Symfony and CakePHP are overkill for a simple application, but it all depends on goal. If you just wanna build the application fast and dirty make some scripts and it will work fine.

However, if you really want to learn good OO design practices and deep knowledge from some of the top frameworks out there the go for the kill 🙂

For small scale PHP development you can use MVC framework. It will allow you to have your codes and folders organized. One of which is CodeIgniter. They have good manual which is also included when you download their framework and they have a much bigger community.

But if you want to make your own framework you can try this folder structure.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>lib/ == contains your classes
app/
app/view == contains the templates
app/model == contains the business logics
app/controler/ == contains the implementations of the business logics
config/ == site configurations
index.php
.htaccess
</code>
<code>lib/ == contains your classes app/ app/view == contains the templates app/model == contains the business logics app/controler/ == contains the implementations of the business logics config/ == site configurations index.php .htaccess </code>
lib/ == contains your classes
app/
app/view == contains the templates
app/model == contains the business logics
app/controler/ == contains the implementations of the business logics
config/ == site configurations
index.php
.htaccess

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật