@
@
@coderiter2019-12-17 04:20:27
Composer
@coderiter, 2019-12-17 04:20:27

Can Composer be configured to put all package files in a shared folder?

Good day to all! The question is in the title of the topic, I'll decipher it a bit:
You need to make a template collector from different pieces. Let's say I have ready-made stretched sections for a Wordpress site: header, slider, text block, contacts. Each of these sections is in my repository. Task: take files from each of these sections, place them in a folder with an initialized Composer, preserving the paths:

#header
/scss/_header.scss
/include/header-fields.php
/include/header-contact-form.php
/js/header.js
header.php

#slider
/css/slick.css
/css/slick-theme.css
/scss/_slider.scss
/js/slider.js
/include/slider-fields.php
/parts/slider.php

As a result, the folder should look like this:
/scss/_header.scss
      /_slider.scss

/css/slick.css
    /slick-theme.css

/include/header-fields.php
         /header-contact-form.php
         /slider-fields.php

/js/header.js
   /slider.js

/parts/slider.php

header.php

Questions:
  1. Is it possible to do so, i.e. in fact ignore namespaces and force everything to be copied into one folder?
  2. Is it possible to pass certain parameters to/through Composer to customize sections? Those. in one variant we write --contact-form:true and the piece with the contact form is placed, in the other - --contact-form:false and the composer does not drag this piece.
  3. In continuation of the last question: is it possible to replace certain variables in files, say, {{param}} with something of my own, passed using Composer?
  4. Is it possible to run my scripts/scripts from an installed package through Composer immediately after installing the script? In fact, scss files will be collected in a common one.
  5. And how will it be possible to update Composer files to new versions, but so that the files in which there were manual changes are not overwritten?

If you know another solution to the problem, also please write.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Nesmeyanov, 2019-12-17
@SerafimArts

To write such things, there is such a thing as "plugins". Composer has an API when installing a dependency that you can use and create whatever you want.
The second link that Dmitry pointed out in the comments is an example of such "creativity". These commands are used there: https://github.com/zendframework/zend-expressive-s... documentation for which is on the composer's website: https://getcomposer.org/doc/articles/scripts.md#co. .. where these methods are called during installation: https : //github.com/zendframework/zend-expressive-s...
There is no documentation on it, but by typing you can try to figure it out on your own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question