duanmu6752 2015-03-11 17:46 采纳率: 0%
浏览 50

PHP多个类,哪个继承,接口,抽象?

I understand basic PHP classes and inheritance, but these don't solve in a elegant way what I want. I have been reading articles and watching video trying to get to grips with more advance OOP. But for the life of me I can not seam to find a neat solution for the following project. Any advice or hints?

I have a web application that is basically a fancy inventory and inspection record. One page has a sortable datatable, pop up dialog boxes and radio buttons to alter an items status. The page has classes for

baseClass = basic page construction, sets database connection and environment values
A dataTable class
A class that generates javascript and jquery code 
A class for managing status radio buttons
Classes and methods for updating the database

The problem is how to code these different class so they can be used on other pages and can be maintained/tweaked simply. At the moment the classes are called as and when needed using spl_autoload_register() but i get stuck ideas about Singleton, Dependancy Injection, Factories.

Any advice? (I am sure its a simple question, but banging my head against the wall is hindering me)

Thanks in advance

  • 写回答

3条回答 默认 最新

  • duanqian2278 2015-03-11 17:51
    关注

    You can try Composer.

    It is very easy and simple (all though, I didn't get a grip how to set up just a simple autoload, from their website). To set up simple autoload I used this tutorial: http://jessesnet.com/development-notes/2014/php-composer-autoloading/

    Also read through PHPBridge it will give you good idea how to set up your classes and later use them with Composer.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端