search
HomeDevelopment ToolscomposerWill this create-project command be used in composer?

This article is introduced by the tutorial column of composer on how to use composer create-project. I hope it will be helpful to friends in need!

Using composer create-project

Preface

Today I used composer create-project to install thinkphp6, which I knew before How to use the create-project command to install the project? It has not been used for a long time. Fortunately, I am not too old yet and can still use my brain, so I just read the document and write down notes.

What to do

When will the composer create-project command be used? Generally speaking, composer require is used to introduce the library, which is very difficult. Use less create-project to install the project. I remember the last time I used this command was when I was writing a project using thinkphp5.1. So what exactly does this sentence do? Here is a quote from the Composer official website

You can use Composer to create a new project from an existing package. This is equivalent to executing a git clone or svn checkout command to install the package's dependencies into its own vendor directory.

We can read this information from the above, it will do two operations:

  • Create a new project from an existing package

  • Install the dependencies in this package to the vendor

That is to say, a new project will be created and the dependencies in this project will be downloaded to the vendor directory. So where does this package come from? Composer said that it will search for the package you specified on packagist.org.

How to use it

If you know what to do, you need to How to use it. The conventional use is composer create-project topthink/think think 5.1.*. Let’s talk about this command in detail. It is divided into four parts.

The first part is composer create-project, which tells composer that we want to create a project. ;

The second part topthink/think is the package name. This package name can be searched on the packagist.org website. If it cannot be found and the project cannot be created, composer will report an error;

The third part think, this is to give the created project a name, which is actually a directory name. If the directory exists, the directory must be empty, otherwise the project creation will fail. If the directory does not exist, it will be automatically created. When choosing an English name, you will encounter some indescribable problems in Chinese

The fourth part is the version of the created project, because the project we created comes from the package in the packagist library, and the package has different versions, so I For example, the created topthink\think has 5.1.* and 5.0.*. If we do not specify a version number, the new version will be created by default. Of course, the specified version 5.1.38 can also be used. You can also use wildcards 5.1.*, assignment operators ~5.1, etc.

parameters

composer create-project This command has some parameters, such as --prefer- dist When there are available packages, install the project from dist, --prefer-source When there are available projects, install from source

Not only the parameters I mentioned above, but also some parameters, but they are always useless at work However, I have not studied it carefully. Even if I read it, I forgot about it at the time. So my first step is to learn the composer create-project command and then learn how to use its parameters.

Others

It does not mean that you can only use composer create-project to create a project with composer. You can also use git clone to clone the project to your computer. There are many methods, just see Which one do you use, for me I prefer using composer create-project to install a thinkphp project

The above is the detailed content of Will this create-project command be used in composer?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:juejin. If there is any infringement, please contact admin@php.cn delete
四大步教你在Debian11上安装使用Composer!四大步教你在Debian11上安装使用Composer!Nov 08, 2022 pm 04:32 PM

本文由composer​教程栏目给大家介绍关于在Debian11上是怎么一步步安装,以及使用Composer的 ,非常详细哦~希望对需要的朋友有所帮助!

Composer是啥Composer是啥Dec 25, 2023 pm 03:06 PM

Composer是PHP的依赖管理工具,它允许开发者将第三方库和框架与自己的项目进行集成。它的主要功能包括:1、依赖管理;2、版本控制;3、自动加载;4、扩展开发;5、集成其他工具。它简化了PHP项目的依赖管理过程,确保项目的稳定性和可维护性。通过使用Composer,开发者可以更加高效地管理自己的项目和集成第三方库和框架。

composer 怎么修改php路径composer 怎么修改php路径Oct 24, 2022 am 11:33 AM

composer修改php路径的方法:1、搜索“composer.bat”并复制到项目文件夹;2、编辑“composer.bat”,将内容修改为“@ECHO OFF php "%~dp0composer.phar" %*”即可。

PHP使用Composer安装和管理依赖包PHP使用Composer安装和管理依赖包Jun 18, 2023 pm 03:30 PM

在PHP开发中,我们经常要处理各种依赖包,这些依赖包可能是其他开发者编写的PHP库文件,也可能是一些第三方工具和框架。为了方便管理这些依赖包,我们可以使用Composer来进行相关的安装和管理工作。Composer是一个开源的PHP依赖管理工具,它可以帮助我们自动化安装、更新和卸载PHP依赖包。通过Composer,我们可以轻松地管理我们应用中的不同依赖,同

使用Composer和PHP包管理器的最佳实践使用Composer和PHP包管理器的最佳实践May 23, 2023 am 08:29 AM

随着PHP的日益流行,PHP开发人员面临着许多挑战,其中包括代码管理、可重用性和依赖性管理。这些问题可以使用包管理器来解决,而Composer是PHP最受欢迎的包管理器之一。在本文中,我们将探讨使用Composer和PHP包管理器的最佳实践,从而提高您的PHP开发效率和代码质量。何为Composer?Composer是一款PHP包管理器,它可以轻松管理PHP

创建composer项目的步骤创建composer项目的步骤Feb 19, 2024 pm 07:13 PM

Composer是一个PHP的依赖管理工具,可以帮助开发者有效地管理项目中的依赖关系。通过Composer,我们可以轻松地引入第三方库、框架以及其他项目所需的各种资源。创建一个Composer项目非常简单,只需按照以下步骤进行操作:首先需要确保在本地已经安装了Composer。可以在终端中运行composer-v命令来确认是否已经安装成功。在项目的根目录中

composer动画怎么保存composer动画怎么保存Apr 09, 2024 pm 02:02 PM

要保存 Composer 动画,可以使用 Lottie 文件格式,具体步骤为:导出为 JSON 文件;使用 Lottie 工具创建 Lottie 文件;从 Lottie 文件导出为多种格式,包括 JSON、GIF、MP4、SWF、HTML。

如何在composer上安装和使用如何在composer上安装和使用Feb 19, 2024 pm 09:38 PM

composer是PHP的依赖管理工具,可以方便地安装、更新和管理项目所需的第三方库和依赖。本文将介绍composer的安装与使用,并提供详细的代码示例。一、安装Composer要使用composer,首先需要将其安装到本地开发环境中。以下演示了在Windows系统中安装composer的步骤:打开Composer的官方网站(https://getcompo

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!