Each class has its own file.
There is a class that contains a couple of dozen functions that can be grouped into 3-4 groups according to their purpose. It would be convenient for me if these groups of functions are put into separate files, but at the same time I don’t lose the structure of the class so that the class becomes a class. I'm tired of scrolling long class files.
Those. I want the same class to be represented by several files:
power_class.php
power_class_g1.php
power_class_g2.php
power_class_g3.php
How to implement this correctly ?
1. I have one class on which the site is built. This class has common functions, and there are individual for each section. I don’t feel like writing classes for each section. It would be more convenient for me to extract functions from files from this class. To produce classes is also haemorrhoids.
2. I have Zend Studio. I don’t like this concept of class folding, deployment. All these IDE editors are outdated. In large projects, you have to download folders and files like an athlete, open dozens of files and other hemorrhoids.
I would generally do this: each function is a file. And then so that it is somehow collected automatically in one or several files and poured onto a server ... Or for example, in general, store functions in relational databases ... but this is another song.
I would like editors to be able to virtually collect the functions they need now into one editing window. For example, 1 function from the x.php file, another from the z.php file, one function from a class such-and-such from another ...
3. It seems to me that the programmer’s thinking is restrained by the file system and the concept of text editors. We think at the level of daddies and files, while databases have long existed.
For example, to select functions with the name Convert in a large project - you need to wait when the search bypasses all folders and files, and if it is on a remote server - then write everything is gone. And then if you try to edit them, it means opening ten files with ten windows ...
SOLUTION
I see such a solution to my problem.
1. A function is called that collects a class from several files into a single file class_power.php
acts just like a template engine 2. Then the generated class_power.php is included . 3. The structure of the class that is assembled in
class_power.php
class_main.php - file that describes the structure of the
Class class PowerClass class_part1.php - part of the class as a set of functions class_part2.php - part of the class as a set of functions class_part3.php - part of the class as a set of functions Thus, you can collect several files with the same functions that I see may also be useful. Another solution: This is necessary in order not to waste your time scrolling along a long file, and also to group functions related by meaning or purpose, and at the same time not to lose the class structure.
Those. I want the same class to be represented by several files:
power_class.php
power_class_g1.php
power_class_g2.php
power_class_g3.php
How to implement this correctly ?
1. I have one class on which the site is built. This class has common functions, and there are individual for each section. I don’t feel like writing classes for each section. It would be more convenient for me to extract functions from files from this class. To produce classes is also haemorrhoids.
2. I have Zend Studio. I don’t like this concept of class folding, deployment. All these IDE editors are outdated. In large projects, you have to download folders and files like an athlete, open dozens of files and other hemorrhoids.
I would generally do this: each function is a file. And then so that it is somehow collected automatically in one or several files and poured onto a server ... Or for example, in general, store functions in relational databases ... but this is another song.
I would like editors to be able to virtually collect the functions they need now into one editing window. For example, 1 function from the x.php file, another from the z.php file, one function from a class such-and-such from another ...
3. It seems to me that the programmer’s thinking is restrained by the file system and the concept of text editors. We think at the level of daddies and files, while databases have long existed.
For example, to select functions with the name Convert in a large project - you need to wait when the search bypasses all folders and files, and if it is on a remote server - then write everything is gone. And then if you try to edit them, it means opening ten files with ten windows ...
SOLUTION
I see such a solution to my problem.
1. A function is called that collects a class from several files into a single file class_power.php
acts just like a template engine 2. Then the generated class_power.php is included . 3. The structure of the class that is assembled in
function compile_class(){
}
class_power.php
class_main.php - file that describes the structure of the
Class class PowerClass class_part1.php - part of the class as a set of functions class_part2.php - part of the class as a set of functions class_part3.php - part of the class as a set of functions Thus, you can collect several files with the same functions that I see may also be useful. Another solution: This is necessary in order not to waste your time scrolling along a long file, and also to group functions related by meaning or purpose, and at the same time not to lose the class structure.
{
var $var1;
#class_part1.php#
#class_part2.php#
#class_part3.php#
}
function load_mclass($class="power_class"){
$res[]="class $class{\n";
foreach(glob($class."*") as $c)
$res[]=удалить "" из file_get_contents($c);
$res[]="\n}";
записать $res в файл $class.m.php
подключить $class.m.php
}