Creating a Website Without a Framework [closed]

I’ve been using PHP Frameworks for so long that I’ve actually forgot the “best practices” for create websites without one.

Usually I will use Symfony, or more recently I’ve been using Laravel. A client wants a very simple website, but with certain parts of it dynamic. Due to the nature of the site using WordPress, or a Framework, is out of the question.

I’m a sucker for priding myself on my code, but I feel like I’m asking such a basic question that it’s killing me to ask. But, what are the best practices for creating websites without a Framework?

I like to live by the K.I.S.S (Keep It Simple Stupid!) method of thinking. So, my idea was to just create the .php pages that are required, do any page processing or database interaction on that page, then have the HTML below the closing PHP tag. I would have any helpers/functions in a functions.php file. This is what I remember doing way before I was using Frameworks, and to me it seems like a very old school way of doing things.

I’ve not created a site without a Framework for literally 2+ years, so I’ve lost my way with the basics.

Any advice would be greatly appreciated.

7

You have used Symfony. That is perfect for your need. If you used Symfony, than you will know that you don’t need to use all it’s components. Quite the opposite is the case. You can basically use each of it’s components standalone.

That being said I’d recommend you that you stick with what you know. And even if you would do it without a framework, you would end up with recreating all the stuff a framework already does. It has a reason why frameworks use database abstraction and other forms of abstraction. It makes code much more maintainable.

Going back to the very bad style of programming where you put everything in one php file, is not the solution. It has been never the solution and will never be. People believe it might be basic or quick but in the end it is only a messy code that nobody can maintain.

1

Frameworks are there to make your life easier. And so, like most things, your approach should be determined by the needs of the client.

TL;DR Use a framework, especially if the project is going to grow, otherwise use the simplest and quickest way forward.

If most of your sites are simple sites, with a little bit of dynamic, then I suppose there’s compelling reason to use a framework. However as your project grows, having a good framework is invaluable. I’ve had the unfortunate privilege of working on some complicated software for an insurance firm that was built without a framework. They figured “lets build our own framework, since this project is so small”. Years later it caused headaches.

Personally, I use frameworks for everything. I’ve moved from php to python and use a ‘micro framework’ called flask. Its super quick to get the basics up and running, yet adds structure should a project go. In my php days I used cakePhp and it worked really well for the simple projects I did back then.

If you REALLY don’t want to use an out of the box framework, then design your app using some of the principles you have already learnt from your experience with frameworks.

You could follow the Symfony style, having an Entity represent your objects and acting as a basic abstraction for your DB, then a series of Controller classes which handle the routing and interactions with the view. Then finally, pick a templating language and use that within your view.

As stated, throwing all the code together in a few files is taking a step backwards.

While there is nothing inherently wrong with the idea of rolling a custom framework, the reality is that most ‘frameworkless’ PHP programmers are not really creating interesting content, they are just naive about what comprises a production ready application and repeating the same common security errors over and over again. Consider the following resources just on the security aspect of web applications:

  • The OWASP Top Ten Project (note: that is only the top ten)
  • Security issues in similar frameworks: Symfony, Zend
  • PHP Security Patches
  • Browser updates (ie, chrome, firefox, android, ios, etc…)

You should be aware of all of these things even if you use a known framework, the difference is that without a framework, you are solely responsible for implementing and maintaining these changes alongside the ones for your specific application. With a framework, you have help with most of these issues.

It’s hard for me to buy the idea that a lone programmer can solve these problems any better without spending years of time, and while having a specific application to build aside from the web framework. It is not impossible, but usually those that succeed release their work as another framework, so unless that is your intention, it is not advised to down the custom framework path.

Also see this answer for more detail.

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