LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   php projects: define each class in a seperate file? (https://www.linuxquestions.org/questions/programming-9/php-projects-define-each-class-in-a-seperate-file-231341/)

ldp 09-16-2004 09:35 AM

php projects: define each class in a seperate file?
 
Hi,
I'm new to php but want to start a little project to learn more about it.
I remember that in java, I was supposed to define each class in a seperate file and then include those files in the program when needed.
Is there a similar type of convention for php classess?

I'm using php5 with mysql 4.1.4a.gamma and apache2

I suppose that I have to change the include_path directive in the php.ini config file. Problem is that whenever I change that directive, php seems to ignore this.
It might be that I am changing the wrong php.ini file?

root@lieven:/usr/local/php5/lib/php# find / -name php.ini
/etc/php4/apache/php.ini
/usr/local/lib/php.ini
/usr/local/src/php-4.3.7/pear/tests/php.ini
/usr/local/src/php-5.0.1/pear/tests/php.ini
/usr/share/doc/php4/examples/php.ini

=> thus I tought that I had to change the "/usr/local/lib/php.ini" file:
(The goal is that all files in the subdirectories from "/usr/local/apache2/htdocs/magic/" can be used with the include statement.
...
safe_mode_include_dir = ".:/php/includes:/usr/local/apache2/htdocs:/usr/local/apache2/htdocs/magic/class"
...
#paths and directories
include_path = ".:/php/includes:/usr/local/apache2/htdocs:/usr/local/apache2/htdocs/magic/class"
...

but that didn't help even after restarting the apache server.

And in "http://lieven.isa-geek.net:8123/php/system.php" it's not clear to me which php.ini file is used by apache/php

thanks,
Lieven

Cedrik 09-16-2004 02:21 PM

From that :
Configuration File (php.ini) Path : /usr/local/php5/lib

Look at /usr/local/php5/lib if there is no php.ini around, if not you have to copy one into it.

ldp 09-16-2004 03:57 PM

Thanks, that solved it indeed. There was no php.ini yet there so I copied the php.ini.recommended to it and altered that file's "include_path" directive.
Now at least, there is no error anymore.
Do you have any idea if it's commonly used to create each class in a seperate file with php? I remember it was done like that at school with java. :rolleyes:

regards,
Lieven

Cedrik 09-16-2004 04:43 PM

That depends, for my part I group little classes in a same file while I put bigger on separate files. But sometimes I let small class in a separate file too because it will grow up as I add methods step by step in a new class.

ldp 09-16-2004 05:00 PM

ok, I'll think I'll do this like I'm used to.
the typing conventions will be much like c or c++ I assume except that you don't give your variables a fixed type or don't define the return value to be of a certain type. Can be confusing from time to time but that's beyond the scope of this thread I think. :)
thanks for the reply.

Lieven


All times are GMT -5. The time now is 08:20 PM.