That should be it for composer init – it will generate a composer.json file at the root of your project based on the values you've selected.īefore we instal any dependency, let's create a LICENSE file at the top of our project and paste the content of the chosen license in it ( here's the MIT one – you will find the others here). gitignore file, to which you should reply yes. The last question is about adding the vendor directory to the. Keep the default value ( src/) for PSR-4 autoload mapping. We will set our dependencies manually, so answer no when asked about defining them interactively. Make sure to set a value that is recognised by Composer, too. MIT is fine in most cases, but if you need something more specific this guide will help. License: this is up to you, but since the code will be distributed and available publicly, it has to be open source.Package type: choose library (see here).That won't be the case in this tutorial though You may sometimes need to pick dev instead if some of your tool's dependencies aren't marked as stable (see here for details). Author: make sure you set values that you are comfortable sharing publicly.Description: shown as optional but will be required for distribution later on.If you're not sure, you can just pick your GitHub username Package name (/): I distribute all my packages under the vendor name osteel, so in my case, it's osteel/php-cli-demo.It will ask you a series of questions – here is some guidance on how to answer them: Next, open a terminal and clone the project locally, and enter its root directory: No matter what you choose, I will let you know when is a good time to make it public. You can make the repository public straight away if you want, but I like to do so only when the code is pretty much ready. The first thing we need to do is create a GitHub repository named php-cli-demo (or anything you like, but the rest of this guide will refer to this name so it might be simpler to stick to it). If at any time you feel lost, you can also refer to this article's repository. To complete this tutorial, you will need: You will find that you can build a lot of things on top of such a simple foundation, but you can always check out these frameworks later on, should you need extra capabilities. We won't use specialised frameworks like Minicli or Laravel Zero because the goal is not so much to focus on features but to better understand the development, testing, and distribution phases of command-line programs. This tutorial will walk you through the process of creating a simple game running in the terminal, using Symfony's Console component as a bedrock, GitHub Actions for compatibility checking, and Composer for distribution. Yet the language powers many popular tools, either as independent programs or to be used within projects.īe it through its vast ecosystem of libraries and frameworks, its ability to interact with the host, or the versatility of its dependency manager, PHP features everything you need to build and ship powerful CLI applications. When you think of command-line applications, PHP doesn't immediately come to mind. You can also subscribe to the RSS or Atom feed, or follow me on Twitter.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |