-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composer project importer #2785
Conversation
Composer is a popular PHP dependency manager (similar to Bower for Javascript). A natural way to create a new project in PHP is by materializing it from a Composer package like this: composer create-project laravel/laravel /projects/laravel The above command fetches the 'laravel/laravel' Composer package from a central repository (https://packagist.org/) and installs it at the /project/laravel folder. The advantage against cloning a git repository is that `composer create-project` will install all required dependencies. This patch contributes a new Composer plugin that: - Defines a Composer project importer that can import the project source from a Composer package. - Defines an Import Project Registrar that registers the Composer importer into the import project wizard. The Composer project importer uses the 'location' property of the SourceStorage model for the package name. As result the "source" of project templates can be defined like this: "source": { "type": "composer", "location": "zendframework/zend-expressive-skeleton", "parameters": {} } Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
Can one of the admins verify this patch? |
At this rate of improements, Kaloyan is going to be a Che committer before CheConf. @bmicklea @vparfonov - please schedule code review / QA into the current sprint. |
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
The second commit renames the 'Archive' importer category to 'Package'. We used to have only the Zip importer in the Archive category, but this PR also adds the Composer one. Renaming the category to 'Package' fits both Zip and Composer importers, whereas 'Archive' is not good for the Composer importer. I kept the ARCHIVE enum class as deprecated for backward compatibility. This commit can be easily reverted if this change is not accepted. |
Very cool @kaloyan-raev! |
- Zend Framework Skeleton Application - Zend Expressive Skeleton Application Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
@kaloyan-raev - is this PR ready for review? Or are you still working on this? |
@bmicklea The PR is ready for review. |
@vparfonov - please review for M7 |
Good things and good case, congrats It seems PHP - Composer relationship looks exactly like Java - Maven one.
|
@gazarenkov Thanks for the review and the advice. Indeed, the PHP - Composer relationship is similar to the Java - Maven. I will look at the Maven plugin as you have suggested and try to rework this PR. |
Cool, feel free to ask me or @vparfonov if you need some help with that, good luck. |
@gazarenkov I looked at the Maven plugin. I agree that from a design point of view it would be better to move the creation of a Composer project from the Import Project wizard to the Create Project wizard. However, the main motivation for this PR was to make it possible to have project templates that are created directly from a composer package. I would still need the project importer to achieve this, right? |
@gazarenkov @vparfonov Could you look at my last question? |
@kaloyan-raev Hi, I don't know how composer work but look like we don't need it as importer. Importer means that you have some remote, for example VCS. If composer just generate some files like maven archetype plugin it's org.eclipse.che.api.project.server.handlers.CreateProjectHandler in our Project API. |
@vparfonov Quote from the
So it does fetch source code. And it also installs the required dependencies. It is the preferred way in the PHP world to start coding on a project template. My main goal is to have Che project templates created from Composer packages. I still need the project importer to achieve this, don't I? Let me know if I can achieve it in another way. I can still refactor the GUI part and plug into the Create Project wizard, instead of to the Import Project wizard. |
I removed the IDE plugin that extends the Import Project wizard from this PR, so we can focus entirely on the ability to create project templates from a Composer package, i.e. with I will prepare a new PR with IDE plugin extending that Create Project wizard after we merge this PR. |
@kaloyan-raev we have fixed Maven Archetype Project generator here 9951639 i think you can do the same with composer |
@vparfonov Can you give me an example how I can use the Maven Archetype Project generator in a project template? |
Conflicts resolved. |
Hi @kaloyan-raev. We added new method in Project API ProjectService.java#L211 it accepts NewProjectConfigDto.java, so you can set in |
@vparfonov I am trying to rework the PR as you suggest. Now I have a Composer project type extending the PHP project type. I also have a CreateProjectHandler. But I am failing to pass any Here is my definition in sampled.json: {
"name": "zend-expressive",
"displayName": "zend-expressive",
"path": "/zend-expressive",
"description": "A skeleton application using the Zend Exressive framework. Expressive is a minimalist PSR-7 middleware framework for PHP with routing, DI container, optional templating, and optional error handling capabilities.",
"projectType": "composer",
"mixins": [],
"attributes": {
"language": [
"php"
],
"package": [
"zendframework/zend-expressive-skeleton"
]
},
"options": {
"package": "zendframework/zend-expressive-skeleton"
},
"modules": [],
"problems": [],
"source": {},
"commands": [
{
"name": "configure",
"type": "custom",
"commandLine": "chmod 777 ${current.project.path}/data/cache; echo \"<VirtualHost *:80>\n DocumentRoot ${current.project.path}/public\n SetEnv APPLICATION_ENV 'development'\n <Directory ${current.project.path}/public>\n DirectoryIndex index.php\n AllowOverride All\n Require all granted\n </Directory>\n</VirtualHost>\" | sudo tee /etc/apache2/sites-available/000-default.conf",
"attributes": {
"previewUrl": ""
}
}
],
"links": [],
"category": "Samples",
"tags": [
"Zend"
]
} Note that I am specifying the "package" value in both |
@kaloyan-raev Can you push your changes to your branch i will check it, thx? |
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
@vparfonov Meanwhile I was able to debug the problem. I created PR #3375 with a potential fix. |
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
Conflicts: dashboard/src/components/typings/che.d.ts plugins/pom.xml
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
@vparfonov I reworked the PR. I take advantage of both the The output of the executed Composer commands are displayed in a Composer console output in the IDE. The plugin also contributes a page to the Create Project wizard where the user can specify a Composer package, which the create the project from. All of the above works pretty nice, but I face some issues that should be addressed separately:
|
@kaloyan-raev I am going to move this to 5.1 - we are trying to finalize M9 which will be the 5.0 GA release and it seems there are more changes needed before this is ready to merge. |
will be merged in #3726 |
What does this PR do?
Composer is a popular PHP dependency manager (similar to Bower for
Javascript). A natural way to create a new project in PHP is by materializing it from a Composer package like this:
The above command fetches the
laravel/laravel
Composer package from a central repository (https://packagist.org/) and installs it at the/project/laravel
folder on the local file system. The advantage against cloning a git repository is thatcomposer create-project
will install all requireddependencies.
This PR contributes a new Composer plugin that:
The Composer project importer uses the 'location' property of the
SourceStorage model for the package name. As result the "source" of
project templates can be defined like this:
The new project importer requires the
composer
executable to be installed in the stack and available in the PATH. This is the usual case for all PHP stacks.Additional changes:
What issues does this PR fix or reference?
New behavior
(Explain the PR as it should appear in the release notes)
Signed-off-by: Kaloyan Raev kaloyan.r@zend.com