How can multiple projects easily depend on the same set of public code?

Source: Internet
Author: User
How can multiple projects easily depend on the same set of public code? I am new to PHP development and want to develop a website. I plan to split it into several projects:

Project. core, project. frontend, project. backend, project. api

In the following several projects, we need to use the common models and helper functions in core projects. how can we achieve this easily? Except for directories that are manually copied: (IDE is zend studio)

Thank you.


Reply to discussion (solution)

If a project (a website you are talking about) is split into several modules (similar to several of your projects), public items should be put forward into a single file, each module can call
If there are several separate projects (independent websites), you 'd better copy them by yourself.

If a project (a website you are talking about) is split into several modules (similar to several of your projects), public items should be put forward into a single file, each module can call
If there are several separate projects (independent websites), you 'd better copy them by yourself.



Thank you. we want to build a platform. we plan to split it into three websites, corresponding to three sets of project files, the front-end part of the website used by users, and our own internal management system, there are also website APIs that use the same library and focus on the same business. a lot of code is generic. if every project has its own set and there are so many repeated codes, the maintenance workload is too heavy.

In the past, I used a compilation language like java and. net. I only needed to reference the compiled jar or dll. I was not very familiar with php. Just now I thought of a tool that could automatically synchronize the entire folder. I feel good at acrobatics...

The three projects you mentioned are actually a website. they can be under a website directory, so they can share code and be recommended.
You can introduce a public php file (require) at the entry file of each project.
Or you can import
If your site directory contains the following files (folder): admin web api common index. php
Introduce the public php file in common in index. php, and then go to admin or web or api

Of course you can. just include it.
You just need to clarify the business logic. Include only common parts

Okay. thank you for your answers. let me try again :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.