Giter VIP home page Giter VIP logo

php-library-starter-kit's Introduction

PHP Library Starter Kit

A starter kit for quickly setting up a new PHP library package.

Source Code Download Package PHP Programming Language Read License Build Status Codecov Code Coverage Psalm Type Coverage

About

ramsey/php-library-starter-kit is a package that may be used to generate a basic PHP library project directory structure, complete with many of the starting files (i.e. README, LICENSE, GitHub issue templates, PHPUnit configuration, etc.) that are commonly found in PHP libraries. You may use the project directory that's created as a starting point for creating your own PHP libraries.

This project adheres to a code of conduct. By participating in this project and its community, you are expected to uphold this code.

Usage

composer create-project ramsey/php-library-starter-kit YOUR-PROJECT-NAME

Running this command will create a new repository containing the same files and structure as this repository. Afterward, it will run the Ramsey\Dev\LibraryStarterKit\Wizard::start() method to set up the project, which will walk you through a series of questions and make changes to files based on your answers. When complete, it will remove the ./src/LibraryStarterKit and ./tests/LibraryStarterKit directories, leaving everything else in place with an initial commit.

Using An Existing Answers File

When executing create-project, if you exit the program while in the middle of the question prompts, you might notice it creates a .starter-kit-answers file in the project directory. When you return later and run composer starter-kit, it will use this file to pre-fill any questions you've already answered. Once finished, the starter kit removes this file.

You may also use an existing answers file to provide all your answers to the prompts, including skipping the question prompts. To do this, set an environment variable with the path to your answers file:

STARTER_KIT_ANSWERS_FILE=/path/to/starter-kit-answers.json

To skip the question prompts, make sure you include the skipPrompts property in the answers file, and set it to true.

The answers file is a JSON object, consisting of all the public properties found in Ramsey\Dev\LibraryStarterKit\Answers.

For example:

{
    "authorEmail": "[email protected]",
    "authorHoldsCopyright": true,
    "authorName": "Author Smith",
    "authorUrl": "https://example.com/",
    "codeOfConduct": "Contributor-2.0",
    "codeOfConductCommittee": null,
    "codeOfConductEmail": "[email protected]",
    "codeOfConductPoliciesUrl": null,
    "codeOfConductReportingUrl": null,
    "copyrightEmail": "[email protected]",
    "copyrightHolder": "Acme, Inc.",
    "copyrightUrl": "https://example.com/acme",
    "copyrightYear": "2021",
    "githubUsername": "example",
    "license": "MIT",
    "packageDescription": "An awesome library that does stuff.",
    "packageKeywords": [
        "awesome",
        "stuff"
    ],
    "packageName": "acme/awesome",
    "packageNamespace": "Acme\\Awesome",
    "projectName": "My Awesome Library",
    "securityPolicy": true,
    "securityPolicyContactEmail": "[email protected]",
    "securityPolicyContactFormUrl": null,
    "skipPrompts": true,
    "vendorName": "acme"
}

Contributing

Contributions are welcome! To contribute, please familiarize yourself with CONTRIBUTING.md.

Coordinated Disclosure

Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. If you believe you've found a security issue in software that is maintained in this repository, please read SECURITY.md for instructions on submitting a vulnerability report.

FAQs

Why did you include package/tool x and not y?

I created this project starter kit for my own uses, and these are the common files, packages, and tools I use in my PHP libraries. If you like what you see, feel free to use it. If you like some of it but not all, fork it and customize it to fit your needs. I hope you find it helpful!

Copyright and License

ramsey/php-library-starter-kit is copyright ยฉ Ben Ramsey and licensed for use under the terms of the MIT License (MIT). Please see LICENSE for more information.

php-library-starter-kit's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar eliatcodecov avatar ramsey avatar szepeviktor avatar upyx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-library-starter-kit's Issues

Disable Unicode Encoding and Slash Escaping of composer.json

Describe the bug

When creating the project, json_encode() encodes unicode characters and escapes slashes.

To Reproduce...

Steps to reproduce the behavior (include code examples, if applicable):

Expected behavior

No unicode (e.g., \u200 encodings. No escaped slashes.

Screenshots or output

N/A

Environment details

  • OS: macOS Mojave (10.14.2)
  • PHP version: 7.2.16
  • ramsey/php-library-skeleton version: 1.1.1

Additional context

Thank you!

Doesn't work on php 8 ๐Ÿคทโ€โ™‚๏ธ

A fatal error on php 8

Description

Fatal error: Declaration of Ramsey\Dev\Tools\Process\Process::getIterator($flags = 0) must be compatible with Symfony\Component\Process\Process::getIterator(int $flags = 0): Generator in /home/upyx/Projects/pik/url-signer/uri-signature/vendor/ramsey/devtools-lib/src/Process/Process.php on line 101

                                                                                                                        
 [ERROR] Array to string conversion                                                                                     
                                                                                                                        
         At line 35 in phar:///usr/bin/composer/vendor/symfony/process/Exception/ProcessFailedException.php             
                                                                                                                       
# php --version
PHP 8.0.10 (cli) (built: Aug 27 2021 21:31:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.10, Copyright (c) Zend Technologies

Content of README.md is the same as composer.json.

Steps to reproduce

Just try

Environment details

  • version of this package: 3.4.1
  • PHP version: 8.0.10
  • OS: Linux (Ubuntu 18.04.6)

Error after fresh install at running composer dev:* script

I made a fresh "create-project" but i can't get it running and have no idea why..

composer dev:analyze:all

Executing dev:analyze:phpstan

Fatal error: Uncaught Error: Call to undefined method Symfony\Component\Process\Process::isTtySupported() in /var/www/html/vendor/ramsey/devtools-lib/src/Composer/Command/ProcessCommand.php:68
Stack trace:
#0 /var/www/html/vendor/ramsey/devtools-lib/src/Composer/Command/BaseCommand.php(94): Ramsey\Dev\Tools\Composer\Command\ProcessCommand->doExecute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php(245): Ramsey\Dev\Tools\Composer\Command\BaseCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /var/www/html/vendor/ramsey/devtools-lib/src/Composer/Command/AnalyzeCommand.php(65): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/html/vendor/ramsey/devtools-lib/src/Composer/Command/BaseCommand.php(94): Ramsey\Dev in /var/www/html/vendor/ramsey/devtools-lib/src/Composer/Command/ProcessCommand.php on line 68

What i don't get is that the symfony process package is installed and of course the static function is available at the process class. I tried making a composer dump-autoload but this changed nothing.

Maybe you have an idea cause i think it's not a (my) client problem cause the github workflows are failing too...

However, cheers and thanks for the lib, it saved me a lot of time using it at one of my libs :)

Support other providers (i.e., GitLab, Bitbucket, etc.)

Support other VCS providers

Add support for VCS providers such as GitLab, Bitbucket, Codeberg, Gitea, etc.

Background/problem

This starter kit wizard currently supports only GitHub, but many folks prefer services such as GitLab, Bitbucket, Codeberg, Gitea, and more. Adding support for other providers would help those who use those providers get started developing PHP libraries more quickly.

Proposal/solution

Add a new question with options to choose a provider. Start with one provider (e.g., GitLab) and ensure the functionality is abstracted in a way that allows adding additional providers easily.

To support new providers, some of the language needs to change in existing wizard questions and documentation. Additionally, the GitHub configuration files in .github/ should have corresponding files added for each provider to resources/templates/provider/. These will be copied to the project when the wizard generates the project files for the user.

Alternatives

Additional context

Shoul composer create-project generate README.md with composer.json content?

I was trying out the library with composer create-project ramsey/php-library-starter-kit contracts to generate a new structure.
I have answered the questions in the prompt (i did not provide a file with answers).
What I ended up with is README.md file that has the contents of a composer.json file. Is this intended?

Note: I was looking at the src/LibraryStarterKit/Task/Builder/UpdateReadme.php and it seems to me that behavior should be different.

Pre answer the questions?

How do I use the answer file or otherwise give the starter kit the answers before running the command?

Crash during install

Description

It crashed during the project creation.

Steps to reproduce

  1. Run the composer command
  2. Answer the questions
  3. Profit

Expected behavior

Run without crashing

Screenshots or output



 [ERROR] The command "'composer' 'dev:test:all'" failed.

         Exit Code: 254(Unknown error)

         Working directory: /Users/matronator/Documents/Work/dev.nosync/ormtr

         Output:
         ================

         Executing lint:syntax
         Unable to execute '/Users/matronator/Library/Application Support/Herd/bin/php83'.

         Executing lint:style
         ... 3 / 3 (100%)


         Time: 84ms; Memory: 10MB


         Executing analyze:phpstan


          [OK] No errors



         Executing analyze:psalm
         ------------------------------

                No errors found!

         ------------------------------

         Checks took 3.09 seconds and used 96.783MB of memory
         Psalm was able to infer types for 100% of the codebase

         Executing test:unit
         PHPUnit 10.5.9 by Sebastian Bergmann and contributors.

         Runtime:       PHP 8.3.0
         Configuration: /Users/matronator/Documents/Work/dev.nosync/ormtr/phpunit.xml.dist

         .                                                                   1 / 1 (100%)

         Time: 00:00.008, Memory: 8.00 MB

         OK (1 test, 1 assertion)


         Error Output:
         ================
         Note: Using configuration file /Users/matronator/Documents/Work/dev.nosync/ormtr/phpstan.neon.dist.
 3/3
         [โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“] 100%

         Target PHP version: 8.1 (inferred from composer.json).
         Scanning files...
         Analyzing files...

         โ–‘


         At line 272 in phar:///usr/local/bin/composer/vendor/symfony/process/Process.php

Environment details

  • version of this package: 3.5.4
  • PHP version: 8.3
  • OS: macOS Ventura (13.4)

Additional context

Error with Windows and Symfony/Process 2.8.52

Hi,

Nice piece of code. I have the same error as described here (#32). It's an array to string conversion error.

I use composer v2.2.3 and the symfony/process version bundled with is the version 2.8.52.
In the log there and error line 263 (https://github.com/symfony/process/blob/v2.8.52/Process.php#L263).
This happen only in windows OS.

After looking at your code there is an error here :

if ($reflectedConstructorType instanceof ReflectionNamedType) {

You look if the first parameter in the constructor has a typehint as "array" and if it's not the case you convert the array to string.
In the v2.8.52 of the Process class there is no typehint so the command is left as an array and you will have the error line 263 of the process.

You should check if there is a typehint as array for the first parameter you don't convert it as a string ELSE you convert it as string.
Same logic as used here : https://github.com/ramsey/devtools-lib/blob/ea4205cc4fb3b68126977deff59742ede8105c90/src/Process/Process.php#L71

I hope i am clear enough.

Keep up the good work.

Error when starting projec

When first installing the project I get an error on Ramsey\Dev\LibraryStarterKit\Wizard::start.

The error is: No arguments expected, got "starter-kit".

I'm using Ubuntu 20.04 and php 7.4

image

What I'm doing wrong?

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.