Giter Site home page Giter Site logo

Comments (10)

MacFJA avatar MacFJA commented on August 12, 2024

You right, build.before is call after parsing all arguments/composer data.

I can add a new event before starting parsing arguments (just after getting the composer.json file path)

from pharbuilder.

kelunik avatar kelunik commented on August 12, 2024

Why not just move the event? Instead of creating a new one?

from pharbuilder.

MacFJA avatar MacFJA commented on August 12, 2024

For several reason:

  • It's doesn't cost anything to add a new event
  • For the same reason I use a true event dispatcher instead of function hook: Extendability
  • build.before happen just the actual build, and the event contains all parsed arguments.

For now, event action are only shell script, but I want to add the same mechanism of composer: have both PHP callable and shell script

from pharbuilder.

kelunik avatar kelunik commented on August 12, 2024

Yes, but I'd expect build.before to happen before any other thing. Which other name do you suggest for the new event?

I'd go with something like

  • dispatch build.before
  • parse and validate args
  • dispatch build.init / build.validate(d)
  • build phar
  • dispatch build.after

On the other hand: build.init is strange after build.before. Maybe build.start?

from pharbuilder.

MacFJA avatar MacFJA commented on August 12, 2024

What I have in my mind was parsing.before.

But you pointing out that my previous choice was not very wise.
Let's find something better. 😁

Here my suggestion:

  • trigger application.start
    • Start the application
    • System check
    • Command init
  • trigger parsing.start (package command only)
    • Read argument from CLI argument, Composer data, then ask
  • trigger parsing.end
  • trigger building.start
    • Create the PHAR archive
  • trigger building.end
  • trigger application.end

from pharbuilder.

kelunik avatar kelunik commented on August 12, 2024

I prefer build instead of building. application.start might be problematic if you add more commands like an about command or so.

I don't know if we want to consider that edge case, but we might want to run certain end hooks when the app is interrupted using Ctrl + C.

from pharbuilder.

MacFJA avatar MacFJA commented on August 12, 2024

build instead of building: OK
application.start (and application.end): I see your concerne, and it's too early to add them, I need more time to find the right way to add them.

For Ctrl-C, Symfony Console don't handle a such case but it's don't seem to hard to add, but it will not work on Windows

from pharbuilder.

kelunik avatar kelunik commented on August 12, 2024

How about command.[build|package].[start|end]? I don't think we should emit events for parsing parameters.

from pharbuilder.

MacFJA avatar MacFJA commented on August 12, 2024

Nice one ! 👍

When should we trigger the start event ?
I need at least to know where is the composer.json file to set the working directory of the shell script (because PharBuilder can be used as an external tool, so the current directory is not necessary the project root)

from pharbuilder.

kelunik avatar kelunik commented on August 12, 2024

Sure, you also need the composer.json to know which events can even be triggered.

from pharbuilder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.