What is "%s"


  • | 483 points

    What is the "%s" in the command "create-project laravel/laravel %s' "? . What does it do? Thanks.


  • | 3712 points

    @kleeh Note that % in %s used for example in the sites.conf file is a script command assignment operator that tells the script that the "s" (meaning "string" variable) will be dynamically replaced or assigned a "value" with the "Name of the App".

    This gives the user the opportunity to name the newly created app on the fly, and then name it to anything they want to.

    Dynamic Project/App naming Example:
    Laravel = composer create-project laravel/laravel %s --prefer-dist

    For example, if you want to "hard-code" the project or app name to remain constant you will do something like this:
    Hard-coded Project/App naming Example:
    Laravel = composer create-project laravel/laravel MyProject --prefer-dist

    Hope it helps!


  • | 37234 points

    @kleeh %s is commonly used as a placeholder by the printf family for formatted output, there are other options like %f for float.


  • | 3712 points

    To follow up on what @Pen-y-Fan stated. And I think his statement carries more value than what might be assumed. It can guide you on a path of powerful discovery should you wish to automate certain aspects of Laragon.

    For purely historical interest, the format specifiers, using the "%" character (%s, %d, %f, etc.) originally seem to come from the C Language, and it has flown into various other languages like Java, PHP, and others.

    In my opinion, it is quite handy to know how a typical CLI handles these, let's call them "core computer commands", function. If it is understood better, it can help you a lot with writing automation scripts, which you can use in the Laragon Procfile.tools and user.cmd configuration files, for example.

    W3 Schools is also a handy starting resource for learning about various
    programming concepts and here is their brief on the %-format specifiers for various data types, for those that are interested.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.