Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
714 views
in Technique[技术] by (71.8m points)

php - How do I separate my executable files from my library files?

I still haven't gotten an answer that I'm happy with. Please do submit some answers if you have a nice system for your Python or PHP projects.


I'm having a management issue with my PHP and Python projects. They both have two kinds of code files: files that should be run in the console or web browser, and files that should be included from other files to extend functionality. After my projects grow into large namespace or module trees, it starts getting disorienting that "executable" files and library files lay side by side with the same file extensions in all my folders. If PHP and Python were pre-compile languages, this would be the files with the main function.

For example, picture I have the namespace com.mycompany.map.address which contained multiple .py or .php files depending on the project. It would contain models for different kinds of addresses and tons of functions for working with addresses. But in addition, it would contain some executable files that runs from the terminal, providing a user tools for searching for addresses, and perhaps adding and removing addresses from a database or such.

I want a way of distinguish such executable files from the tons and tons of code files in my namespace trees

If the files had separate file extensions this wouldn't be a problem. But since they don't, I'm thinking I should separate folders or something, but I don't know what to name them. In PHP I could perform the hack solution of configuring PHP to parse different file extensions, so my project could contain phps or phpx files, for instance.

If anyone has some language-independent advice on how to handle this issue, I'd appreciate it. This could also apply to languages such as C, where one project might compile into many executable files. How should one separate the source files containing main functions from the rest of them?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Separate them somehow (by name, by extension, by location).


Example:

Here's the layout of our test automation system (output is manually sorted for clarity):

$ ls -1 automation
atf                two major homebrew libraries, with many submodules
atflib            / 

atfconfig         configuration files in .py form
configuration      configuration files in .ini form
res_manager       /

test_scripts      - scripts to be invoked directly

Then we place the automation folder into PYTHONPATH and can import atf.<smth> anywhere. To run tests, we change into test_scripts.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...