Tekforums

Chat => Entertainment & Technology => Topic started by: neXus on August 16, 2006, 19:07:43 PM

Title: php packages like java?
Post by: neXus on August 16, 2006, 19:07:43 PM
Expanding my php stuff and im wondering if php can do packages like that of java when you create muilple class and associations.

In Java you would have

package packagename;
import person;

public class bankCustomer extends person {


}


Where the package would allow access to many files and you import what you need

Or do i just keep to what I am doing...
Either lots of import lines
OR
Sometimes i make a file that has relevent stuff
Say part of the site deals with user comments in a blog etc away from its gallery code
You have all the files relevent
so you import database, import person, comments, display, imput blabla

Then when ever your calling its use you import just the one file
Title: php packages like java?
Post by: Mardoni on August 16, 2006, 21:02:05 PM
Yes it can, google for php inheritance
Title: Re:php packages like java?
Post by: neXus on August 16, 2006, 22:33:52 PM
Hi m8, yeah, allready know about inheritance
But i cant see from things on web about how to use them

From a person to a student do you just say "extends person" and it will look for the class file of that object or do you need to do..

include person

As i was asking if you could just declare a package and use whats in it,c ant find anything on that
Title: php packages like java?
Post by: Mardoni on August 17, 2006, 00:05:54 AM
oic what you mean :)

No, afaik there is no way to pre-complie PHP classes into libraries. You have to link them up manually.


require_once("parent.php");

class child extends parent {

}


Title: php packages like java?
Post by: cornet on September 07, 2006, 11:32:30 AM
Just confirming, the answer is no.

PHPs OO stuff is fairly um... basic. Its has only just learned about public and private functions.

... back to doing what have been doing.

Cornet
Title: php packages like java?
Post by: Sam on September 08, 2006, 06:40:11 AM
This is why PHP is crap for large scale development. The compiled source code for my software is 3.25mb.  1395 files (I just checked), imagine trying to link all them together in a meaningful way in PHP.
Title: Re:php packages like java?
Post by: neXus on September 08, 2006, 09:48:37 AM
I found you can do this actually.
You give a name to your project amd have a simple front controller and you just place the name of the project in each file, certain files you direct include for privacy but all have the package assoication.
Title: php packages like java?
Post by: Sam on September 13, 2006, 21:21:53 PM
Its a hack nothing more.