你能在另一个项目中实例化一个类吗?

I wonder if it is possible to make the call of a function that is in a class of another project. This is the structure of both projects:

enter image description here

This would be an anti-pattern use. you want all classes available, by autoloading them. If you need that class, you would want to find a way to implement it into your existing bundle, or add a new bundle containing this helper functionality embedded within so that its loaded in, then use it that way. Otherwise there is no system for this, since it is an anti-pattern.

You should create a repository on GitHub or Bitbucket and add your Project 1 to that repository. This implies:

  1. Creating a Git repository
  2. "Transforming" that local project onto a package using composer (see this for more info)

Having this, you'll simply need to edit the composer.json file on the Laravel project and add your package as a dependency. Once you execute composer update, the Project 1 will be available on the vendor directory and you can instanciate the class by its namespace.