Jump to content

OOP php


Bryce910

Recommended Posts

I have at least 5 classes in a file called library.php, this contains a few factory and static classes which are used quite often. I have a file called singletons.php which contains about 3 singletons inside that file. So it really depends on your coding style and how you want to have everything organized and structured. How you have it set up won't make your code any more/less object oriented.

Link to comment
https://forums.phpfreaks.com/topic/261282-oop-php/#findComment-1338958
Share on other sites

That also depends on how your script is set up. I have many library classes in one file that all have functions that can operate independantly.

So once I include the file basically all classes are autoloaded.

include_once( 'library.php' );
form_lib::function( );
user_lib::function( );
date_lib::function( );

 

Although the very beginning of this page:

http://php.net/manual/en/language.oop5.autoload.php

It says, "Many developers writing object-oriented applications create one PHP source file per-class definition".

 

So really it's up to you. You can do things the way many other developers do them. Or you can find a way that perfectly suits you by creating code to handle these types of instances themselves.

Link to comment
https://forums.phpfreaks.com/topic/261282-oop-php/#findComment-1338964
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.