There is a simple PHP independent library for displaying statistics. It has a frontend that builds diagrams on JS + CSS, which also requires Chart.js in dependencies. How to distribute this bundle entirely? Immediately I say that the backend without the frontend, though it will work, but it is hardly useful to someone. All tsimes precisely in the bundle.

So far only such options came to mind.

  1. All together - PHP + JS + СSS through Сomposer and some asset-manager.
  2. Split into two repositories and distribute the backend through Composer, and the frontend through NPM / Bower.
  3. Use one repository, but put the frontend through NPM / Bower, and the backend via Сomposer.

Maybe there are more ways? How do such projects usually spread?

  • who is this package targeted at? who is his user? - Mikhail Vaysman
  • First of all - CRM, dashboards. But he has no narrow frames. You can fasten anywhere. - qtm
  • not where! who? developer? administrator? integrator? etc? - Mikhail Vaysman
  • Managers, economists. There are current economic statistics. - qtm
  • one
    The difference between NPM and Bower is that NPM is used for the server part, and Bower for the client part. That is, in your case, NPM does not fit - Oceinic

2 answers 2

Let's reason like this: the frontend from your library separately is useless.

Therefore, I see only the distribution option through Composer, with the presentation of the code on Github. Of course, attach some workable version of Chart.js to the project, the MIT license allows it .

For convenience of updating Chart.js, you can attach package.json, noting this fact in the Readme.

So you can get a working library from one source and start using it right away.

  • Thank. Yes, that would be best. - qtm

I think in this formulation - no way !!!. How will this independent library work with different systems, frameworks and differently configured php and rewrite-configured ruls ??? I'm not talking about getting and storing data with SQL and non-SQL solutions.

I think in this case, let's go well with the widget that will be generated somewhere on your website / server. And to everyone who wants to use we will be given a js-file and, accordingly, the code for insertion in the right place.

  • one
    In terms of PHP, we install via Сomposer in the vendor folder and connect to the correct controller. Of course, I understand that there are those who have not heard anything about standards, but this is their problem. JS is less standardized, everyone puts the packages where they want, they collect as they want, but that's why I asked this question. SQL is not there at all. Data is taken from the API. If implemented as a widget, you will have to load Chart.js anyway. And this is the first point. Asset Manager? - qtm
  • Do you offer to make a service from the library? - Nick Volynkin
  • I suggest making a widget from the library. - qtm