agentejo / cockpit

Add content management functionality to any site - plug & play / headless / api-first CMS
http://getcockpit.com
MIT License
5.4k stars 523 forks source link

Install cockpit as a composer dependency #261

Closed youknowriad closed 8 years ago

youknowriad commented 9 years ago

Hi, Is there a way yo install cockpit as a composer dependency and have the custom config outside the vendor folder.

Thanks a lot

aheinze commented 9 years ago

hi,

the only possible way I can think of are composer scripts: https://getcomposer.org/doc/articles/scripts.md

youknowriad commented 9 years ago

Hi,

I think if cockpit is intended to be for developers, it should be easy to install and update with developers tools (composer pour PHP). I think your point (am I wrong) is to make easy to use, juste copy/paste and launch a webserver, but for many developpers like, we want to be able to add the cockpit code to .gitignore and we want it to be outside the public path, update it easily with composer and custom some paths (cache, storage).

I've tried some things, override some consts and symlink assets, but I've not the required knowledge of how the CSM is organised to make this work. May be you should consider having two install methods ? one with composer with the ability to custom paths and one copy/paste method.

Thanks

omnilight commented 9 years ago

I agree with @youknowriad , you should provide way to customize paths for cockpit out of the box.

For example currently I see one problem: you define bootstrap.php in your composer.json and this makes it impossible to change any constants in this file after composer load.

Maybe you should exclude this file from autoloading, or at least maybe create separate repository that can be used for composer dependecies, and another repository for installing cockpit as standalone application

piotr-cz commented 9 years ago

I've got idea. Maybe it would be possible trough Composer Installers.

_If there would a package type publicFolder with destination of public subfolder (public, web or public_html)_, and Cockpit's composer.json would look like:

"name": "aheinze/cockpit",
"type": "publicFolder",
"extra": {
    "installer-name": "cockpit"
}

then using composer it should get installed to public/cockpit folder.

youknowriad commented 9 years ago

@piotr-cz Not a bad idea

piotr-cz commented 9 years ago

Maybe cleaner way is to register cockpit installer type for composer. Additionally it would open possibility to install modules using composer:

Cockpit application destination: ./public/cockpit

{
  "name": "aheinze/cockpit",
  "type": "cockpit-core",
  "extra": {
    "installer-name": "cockpit"
  }
}

Example module destination: ./public/cockpit/modules/addons

{
  "name": "verdorName/FooBar",
  "type": "cockpit-module",
  "extra": {
    "installer-name": "FooBar"
  }
}

Downside is that the public folder should be pre-set (hardcoded) in the installer type. Maybe it's possible overwrite it with a CLI parameter, but haven't investigated further.

If you are wondering, why there is an extra.installer-name key, it makes the target install directly into such subfolder instead of default composer scheme vendor/productName. But it may not be necessary (See JoomlaInstaller.php)

aheinze commented 9 years ago

@piotr-cz awesome

piotr-cz commented 9 years ago

I vote for public name as it seems most explicit to me. By inspecting Base installer.php file maybe it's possible to change it in root composer.json file with handling something like extra.publicPath.

aheinze commented 9 years ago

do I need to change anything in cockpits composer.json?

piotr-cz commented 9 years ago

I'm not sure I understood correctly the purpose of installer-name but IMHO it doesn't make sense to play with it without above steps anyway.

BTW: All of this is theory, I haven't tried it out.

piotr-cz commented 9 years ago

Another option would be to create an installer similar to Laravel installer (GitHub repo, Docs) or Lumen installer (GitHub repo, Docs).

jbrooksuk commented 9 years ago

This would be idea for us, since we build our websites with Laravel, we just want to use the helper methods collection or region etc within our existing code. We handle routing etc, but want to use the helpers only.

piotr-cz commented 9 years ago

One more and maybe most easiest option is to treat Cockpit like a frontend component (jQuery/ Bootstrap) using Component Installer for Composer

So in projects composer.json file we'd define

{
    "require": {
        "components/cockpit": "~0.13"
    }
}
royduin commented 9 years ago

Any updates on this one? Maybe an idea to do it like Bedrock does for Wordpress? See:

royduin commented 9 years ago

Relevant to this issue: https://github.com/mnsami/composer-custom-directory-installer/issues/11

piotr-cz commented 8 years ago

I've added support for Cockpit modules as composer installers. New version that includes aforementioned commit It's not released yet

See https://github.com/composer/installers/pull/284 for details.

omzy commented 6 years ago

So, what is the process for installing Cockpit as a Composer dependency? For example I want to use Cockpit as a CMS for Laravel, since it is a 3rd party package it should be installed to the vendor folder, and not manually copied to the public folder. The Cockpit storage folder can/should exist in the public folder however.

What is the correct way of doing this?