Composer は、PHP で依存関係を管理するために使用されるツールです。プロジェクト内で依存する外部ライブラリ (ライブラリ) を宣言すると、Composer がこれらの依存ライブラリ ファイルをインストールします。
PHP Composer のインストール
システム要件:
Composer を実行するには、PHP5.3.2 以降が必要です。いくつかの機密性の高い PHP 設定とコンパイル フラグも必要ですが、非互換性が存在する場合、インストーラーは警告を発行します。
たとえば、PHP 拡張機能の要件は、-disable-phar を指定せずに php をインストールまたは再コンパイルすることです。
単純な圧縮ファイル パッケージではなくソース アドレスからパッケージをインストールするには、次のようにします。 git、svn、hg などのソフトウェア パッケージのバージョン管理ツールをインストールする必要があります。
Composer はマルチプラットフォーム互換性があり、Windows、Linux、OSX 上で実行できます。
インストールに失敗したエラー メッセージ:
curl -sS https://getcomposer.org/installer | PHP #!/usr/bin/env php some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again: The phar extension is missing. Install it or recompile php without –disable-phar Your PHP (5.2.9) is too old, you must upgrade to PHP 5.3.2 or higher.
私のローカルのデフォルト開発環境は PHP 5.2.9 で、PHP にインストールしようとすると5.2. 9 にインストールすると、バージョンが低すぎるため、PHP 5.3.2 以降にアップグレードする必要があるというメッセージが表示されます。
そこで、XAMPP 1.7.7 usb lite バージョンをダウンロードしました。
E:\USB\Dropbox\phpstorm\php53>E:\USB\xampp_177\php\php.exe -v PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
XAMPP 1.7.7 での PHP 環境は 5.3.8 です。私のPHP環境がPHP5.3.2以上であることを確認したところ。
PHP 5.3 Composer のインストール
E:\USB\Dropbox\phpstorm\php53>curl -sS https://getcomposer.org/installer | E:\USB\xampp_177\php\php.exe #!/usr/bin/env php Some settings on your machine may cause stability issues with Composer. If you encounter issues, try to change the following: The openssl extension is missing, which will reduce the security and stability o f Composer. If possible you should enable it or recompile php with –with-openssl Downloading… Composer successfully installed to: E:\USB\Dropbox\phpstorm\php53\composer.phar Use it: php composer.phar
注:
XAMPP 1.7.7 をオフにしましたApache の SSL モジュールであるため、Composer は警告を表示し、セキュリティ上の理由から SSL モジュールを有効にすることを提案しました。オンにしなくても使用には影響ありません。
PHP のインストール中のパラメータは、 | E:\USB\xampp_177\php\php.exe などの実際の PHP 環境パスに変更する必要があります。
インストールした環境では、PHP パス コマンドとして Composer を使用します。 , 使用方法は、E:\USB\xampp_177\php/php.execomposer.pharコマンドです。
私がインストールした環境が Windows であり、PHP 5.3 環境がデフォルトの PHP コマンドではない場合は、次のように /usr/php/53/usr/bin/php を使用する必要があります。
##
curl -sS https://getcomposer.org/installer | /usr/php/53/usr/bin/phpインストールが完了したら、インストールのバージョンを確認します。
E:\USB\Dropbox\phpstorm\php53>E:\USB\xampp_177\php/php.exe composer.phar -V Composer version 0209bd31a0ac3aeb2a68fc81e2d03c71072bef33PHP Composer コマンドを確認してください:
E:\USB\Dropbox\phpstorm\php53>E:\USB\xampp_177\php/php.exe composer.phar ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 0209bd31a0ac3aeb2a68fc81e2d03c71072bef33 Usage: [options] command [arguments] Options: –help -h Display this help message. –quiet -q Do not output any message. –verbose -v Increase verbosity of messages. –version -V Display this application version. –ansi Force ANSI output. –no-ansi Disable ANSI output. –no-interaction -n Do not ask any interactive question. –profile Display timing and memory usage information –working-dir -d If specified, use the given directory as working directory . Available commands: about Short information about Composer archive Create an archive of this composer package config Set config options create-project Create new project from a package into given directory. depends Shows which packages depend on the given package diagnose Diagnoses the system to identify common errors. dump-autoload Dumps the autoloader dumpautoload Dumps the autoloader help Displays help for a command init Creates a basic composer.json file in current directory. install Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json. list Lists commands require Adds required packages to your composer.json and installs the m run-script Run the scripts defined in composer.json. search Search for packages self-update Updates composer.phar to the latest version. selfupdate Updates composer.phar to the latest version. show Show information about packages status Show a list of locally modified packages update Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file. validate Validates a composer.jsonこのようにして、 PHP5.3環境 以下のComposerがインストールされています。 同様に、PHP 5.4 環境をインストールすることもできます。
PHP 5.4 Composer のインストール
XAMPP 1.8.1 usb lite バージョンをダウンロードすると、PHP5.4.7 環境が得られます。 #E:\USB\Dropbox\phpstorm\php53>E:\USB\xampp_181\php\php.exe -v PHP 5.4.7 (cli) (built: Sep 12 2012 23:48:31) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies#バージョンが PHP 5.3.2 以降であることを確認したら、インストールを開始します。
#
E:\USB\Dropbox\phpstorm\php54>curl -sS https://getcomposer.org/installer | E:\USB\xampp_181\php\php.exe #!/usr/bin/env php Some settings on your machine may cause stability issues with Composer. If you encounter issues, try to change the following: The openssl extension is missing, which will reduce the security and stability o f Composer. If possible you should enable it or recompile php with –with-openssl Downloading… Composer successfully installed to: E:\USB\Dropbox\phpstorm\php54\composer.phar Use it: php composer.pharインストールが完了したら、インストールされているバージョンを確認します。
E:\USB\Dropbox\phpstorm\php54>E:\USB\xampp_181\php/php.exe composer.phar -V Composer version 0209bd31a0ac3aeb2a68fc81e2d03c71072bef33これで、PHP 5.4 環境の Composer も正常にインストールされました。
PHP Composer の使用法
ここでは、PHP Composer を使用して Symfony フレームワークをインストールする方法を簡単に説明します。
まず、コマンドの標準形式を簡単に説明します。php composer.phar create-project symfony/framework-standard-edition path/ 2.2.1最初のパラメータ PHP は、ローカルの PHP 開発環境を指します。 PHP 実行コマンドに。
2 番目のパラメータは、composer.phar モードでダウンロードされます。
3 番目のパラメータは、create-project などのアクション コマンドです。その目的は、ソフトウェア パッケージから指定されたディレクトリに新しいプロジェクトを作成することです。4 番目のパラメータは、ローカル インストールのディレクトリです。
5 番目のパラメータは、インストールされているソフトウェア パッケージのバージョンです。
上記に従って、Composer を PHP5.4 環境にインストールしました。インストール コマンドは次のとおりです:
E:\USB\Dropbox\phpstorm\php54>E:\USB\xampp_181\php/php.exe composer.phar create-project symfony/framework-standard-edition E:\USB\xampp_181\htdocs\Symfony 2.2.1インストール結果:
Installing symfony/framework-standard-edition (v2.2.1) – Installing symfony/framework-standard-edition (v2.2.1) Downloading: 100% Created project in E:\USB\xampp_181\htdocs\Symfony Loading composer repositories with package information Installing dependencies from lock file – Installing doctrine/lexer (v1.0) Downloading: 100% – Installing doctrine/annotations (v1.1) Downloading: 100% – Installing doctrine/cache (v1.0) Downloading: 100% – Installing doctrine/collections (v1.1) Downloading: 100% – Installing twig/twig (v1.12.2) Downloading: 100% – Installing psr/log (1.0.0) Downloading: 100% – Installing doctrine/inflector (v1.0) Downloading: 100% – Installing doctrine/common (2.4.0-RC1) Downloading: 100% – Installing symfony/symfony (v2.2.1) Downloading: 100% – Installing jdorn/sql-formatter (v1.2.0) Downloading: 100% – Installing doctrine/dbal (2.3.3) Downloading: 100% – Installing doctrine/doctrine-bundle (v1.2.0-beta1) Downloading: 100% – Installing doctrine/orm (2.3.3) Downloading: 100% – Installing jms/cg (1.0.0) Downloading: 100% – Installing phpoption/phpoption (1.2.0) Downloading: 100% – Installing jms/parser-lib (1.0.0) Downloading: 100% – Installing jms/metadata (1.3.0) Downloading: 100% – Installing jms/aop-bundle (1.0.0) Downloading: 100% – Installing jms/di-extra-bundle (1.3.0) Downloading: 100% – Installing jms/security-extra-bundle (1.4.0) Downloading: 100% – Installing sensio/distribution-bundle (v2.2.1) Downloading: 100% – Installing sensio/framework-extra-bundle (v2.2.1) Downloading: 100% – Installing sensio/generator-bundle (v2.2.1) Downloading: 100% – Installing kriswallsmith/assetic (v1.1.0-alpha4) Downloading: 100% – Installing symfony/assetic-bundle (v2.1.2) Downloading: 100% – Installing monolog/monolog (1.4.1) Downloading: 100% – Installing symfony/monolog-bundle (v2.2.0) Downloading: 100% – Installing swiftmailer/swiftmailer (v4.3.0) Downloading: 100% – Installing symfony/swiftmailer-bundle (v2.2.0) Downloading: 100% – Installing twig/extensions (v1.0.0) Downloading: 100% kriswallsmith/assetic suggests installing leafo/lessphp (Assetic provides the integration with the lessphp LESS compiler) kriswallsmith/assetic suggests installing leafo/scssphp (Assetic provides the integration with the scssphp SCSS compiler) kriswallsmith/assetic suggests installing leafo/scssphp-compass (Assetic provides the integration with the SCSS compass plugin) kriswallsmith/assetic suggests installing ptachoire/cssembed (Assetic provides the integration with phpcssembed to embed data uris) monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server) monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required)) monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server) monolog/monolog suggests installing mlehner/gelf-php (Allow sending log messages to a GrayLog2 server) monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server) Generating autoload files Clearing the cache for the dev environment with debug true Installing assets using the hard copy option Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework Installing assets for Acme\DemoBundle into web/bundles/acmedemo Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
#コマンドラインの結果から、Symfony フレームワーク全体のインストールプロセスと結果がわかります。
PHP Composer による依存関係の定義Composer は、使用時に、composer.json ファイルを自動的に検索します。 combos.json は、プロジェクト全体の依存関係パッケージを定義するために使用されます。例:
{ "require": { "monolog/monolog": "1.2.*" } }
依存関係パッケージ 簡単に説明すると、このプロジェクトには 1.2 以降の任意のバージョンのいくつかの monolog/monolog パッケージが必要です。
Composer は、PHP の依存関係管理ツールです。 Composer を使用すると、ソフトウェアを公開するときに多くのファイルを保存し、依存パッケージのバージョンを制御できます。
上記がこの記事の全内容です。その他の関連コンテンツについては、PHP 中国語 Web サイトをご覧ください。
関連する推奨事項:
PHP フレームワーク Laravel プラグインについて カスタム ページングを実装するためのページネーション メソッド以上がPHP 依存関係管理ツール Composer のインストールと使用についての詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

tomodifydatainaphpsession、starthessession withsession_start()、$ _sessiontoset、modify、orremovevariables.1)startthessession.2)

配列はPHPセッションに保存できます。 1。セッションを開始し、session_start()を使用します。 2。配列を作成し、$ _Sessionで保存します。 3. $ _Sessionを介して配列を取得します。 4.セッションデータを最適化してパフォーマンスを向上させます。

PHPセッションガベージコレクションは、有効期限が切れたセッションデータをクリーンアップするために確率メカニズムを通じてトリガーされます。 1)構成ファイルにトリガー確率とセッションのライフサイクルを設定します。 2)Cronタスクを使用して、高負荷アプリケーションを最適化できます。 3)データの損失を避けるために、ごみ収集の頻度とパフォーマンスのバランスを取る必要があります。

PHPでのユーザーセッションアクティビティの追跡は、セッション管理を通じて実装されます。 1)SESSION_START()を使用してセッションを開始します。 2)$ _Sessionアレイを介してデータを保存およびアクセスします。 3)セッションを終了するには、session_destroy()を呼び出します。セッショントラッキングは、ユーザーの動作分析、セキュリティ監視、パフォーマンスの最適化に使用されます。

データベースを使用してPHPセッションデータを保存すると、パフォーマンスとスケーラビリティが向上します。 1)MySQLを構成してセッションデータを保存します:PHP.iniまたはPHPコードでセッションプロセッサを設定します。 2)カスタムセッションプロセッサを実装します:データベースと対話するために、開いて、閉じ、読み取り、書き込み、その他の機能を定義します。 3)最適化とベストプラクティス:インデックス、キャッシュ、データ圧縮、分散ストレージを使用して、パフォーマンスを向上させます。

phpssionsStrackuserdataacrossmultiplepagerequestsusingauniqueidstoredinacookie.here'showtomanageetheemefectively:1)Startassession withsession_start()andstoredatain $ _ session.2)RegeneratesseSsessidafterloginwithsession_id(the topreventes_id)

PHPでは、次の手順を通じてセッションデータを繰り返すことができます。1。session_start()を使用してセッションを開始します。 2。$ _Sessionアレイのすべてのキー価値ペアを介してforeachループを反復します。 3.複雑なデータ構造を処理する場合、is_array()またはis_object()関数を使用し、print_r()を使用して詳細情報を出力します。 4.トラバーサルを最適化する場合、ページングを使用して、一度に大量のデータの処理を避けることができます。これにより、実際のプロジェクトでPHPセッションデータをより効率的に管理および使用するのに役立ちます。

このセッションは、サーバー側の状態管理メカニズムを介してユーザー認証を実現します。 1)セッションの作成と一意のIDの生成、2)IDはCookieを介して渡されます。3)サーバーストアとIDを介してセッションデータにアクセスします。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

mPDF
mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

ホットトピック









