https://blog.csdn.net/u011944141/article/details/79569917
composer create-project --prefer-dist cakephp/app my_php_cake
提示信息如下:
Installing cakephp/app (3.7.1)
- Installing cakephp/app (3.7.1): Downloading (100%)
Created project in my_php_cake
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- cakephp/cakephp 3.7.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.7.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.7.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.7.4 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.7.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.7.2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.7.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.7.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- Installation request for cakephp/cakephp 3.7.* -> satisfiable by cakephp/cakephp[3.7.0, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.2/cli/php.ini
- /etc/php/7.2/cli/conf.d/10-opcache.ini
- /etc/php/7.2/cli/conf.d/10-pdo.ini
- /etc/php/7.2/cli/conf.d/15-xml.ini
- /etc/php/7.2/cli/conf.d/20-bcmath.ini
- /etc/php/7.2/cli/conf.d/20-bz2.ini
- /etc/php/7.2/cli/conf.d/20-calendar.ini
- /etc/php/7.2/cli/conf.d/20-ctype.ini
- /etc/php/7.2/cli/conf.d/20-curl.ini
- /etc/php/7.2/cli/conf.d/20-dom.ini
- /etc/php/7.2/cli/conf.d/20-exif.ini
- /etc/php/7.2/cli/conf.d/20-fileinfo.ini
- /etc/php/7.2/cli/conf.d/20-ftp.ini
- /etc/php/7.2/cli/conf.d/20-gd.ini
- /etc/php/7.2/cli/conf.d/20-gettext.ini
- /etc/php/7.2/cli/conf.d/20-iconv.ini
- /etc/php/7.2/cli/conf.d/20-igbinary.ini
- /etc/php/7.2/cli/conf.d/20-json.ini
- /etc/php/7.2/cli/conf.d/20-mbstring.ini
- /etc/php/7.2/cli/conf.d/20-msgpack.ini
- /etc/php/7.2/cli/conf.d/20-pdo_pgsql.ini
- /etc/php/7.2/cli/conf.d/20-pgsql.ini
- /etc/php/7.2/cli/conf.d/20-phar.ini
- /etc/php/7.2/cli/conf.d/20-posix.ini
- /etc/php/7.2/cli/conf.d/20-readline.ini
- /etc/php/7.2/cli/conf.d/20-redis.ini
- /etc/php/7.2/cli/conf.d/20-shmop.ini
- /etc/php/7.2/cli/conf.d/20-simplexml.ini
- /etc/php/7.2/cli/conf.d/20-sockets.ini
- /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.2/cli/conf.d/20-sysvsem.ini
- /etc/php/7.2/cli/conf.d/20-sysvshm.ini
- /etc/php/7.2/cli/conf.d/20-tokenizer.ini
- /etc/php/7.2/cli/conf.d/20-wddx.ini
- /etc/php/7.2/cli/conf.d/20-xmlreader.ini
- /etc/php/7.2/cli/conf.d/20-xmlwriter.ini
- /etc/php/7.2/cli/conf.d/20-xsl.ini
- /etc/php/7.2/cli/conf.d/20-zip.ini
- /etc/php/7.2/cli/conf.d/25-memcached.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
上边的问题其实从下边这句找出
Problem 1
- cakephp/cakephp 3.7.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
结论缺少 php-intl 扩展
$sudo apt-get install php7.2-intl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-image-4.15.0-47-generic linux-modules-4.15.0-47-generic linux-modules-extra-4.15.0-47-generic linux-tools-4.15.0-47 linux-tools-4.15.0-47-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
php7.2-intl
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 124 kB of archives.
After this operation, 512 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 php7.2-intl amd64 7.2.17-0ubuntu0.18.04.1 [124 kB]
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 php7.2-intl amd64 7.2.17-0ubuntu0.18.04.1 [124 kB]
Fetched 123 kB in 52s (2,377 B/s)
Selecting previously unselected package php7.2-intl.
(Reading database ... 316636 files and directories currently installed.)
Preparing to unpack .../php7.2-intl_7.2.17-0ubuntu0.18.04.1_amd64.deb ...
Unpacking php7.2-intl (7.2.17-0ubuntu0.18.04.1) ...
Processing triggers for php7.2-fpm (7.2.17-0ubuntu0.18.04.1) ...
Setting up php7.2-intl (7.2.17-0ubuntu0.18.04.1) ...
Creating config file /etc/php/7.2/mods-available/intl.ini with new version
Processing triggers for libapache2-mod-php7.2 (7.2.17-0ubuntu0.18.04.1) ...
Warning: Could not load Apache 2.4 maintainer script helper.
Processing triggers for php7.2-fpm (7.2.17-0ubuntu0.18.04.1) ...
$ composer create-project --prefer-dist cakephp/app my_php_cake
Installing cakephp/app (3.7.1)
In ProjectInstaller.php line 65:
Project directory my_php_cake/ is not empty.
create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [] [] []
出现这个是因为在my_php_cake 目录下已经有 composer.jon 文件了,故而只需 命令行只需 composer install 即可
$ composer install --no-dev
Loading composer repositories with package information
Updating dependencies
Package operations: 18 installs, 0 updates, 0 removals
- Installing cakephp/plugin-installer (1.1.0): Downloading (100%)
- Installing aura/intl (3.0.0): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing zendframework/zend-diactoros (1.8.6): Downloading (100%)
- Installing psr/simple-cache (1.0.1): Downloading (100%)
- Installing psr/log (1.1.0): Downloading (100%)
- Installing cakephp/chronos (1.2.5): Downloading (100%)
- Installing cakephp/cakephp (3.7.7): Downloading (100%)
- Installing symfony/polyfill-ctype (v1.11.0): Downloading (100%)
- Installing symfony/yaml (v4.2.8): Downloading (100%)
- Installing symfony/filesystem (v4.2.8): Downloading (100%)
- Installing symfony/config (v4.2.8): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.11.0): Downloading (100%)
- Installing symfony/contracts (v1.1.0): Downloading (100%)
- Installing symfony/console (v4.2.8): Downloading (100%)
- Installing robmorgan/phinx (0.10.7): Downloading (100%)
- Installing cakephp/migrations (2.1.1): Downloading (100%)
- Installing mobiledetect/mobiledetectlib (2.8.33): Downloading (100%)
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
setfacl -R -m u:${HTTPDUSER}:rwx tmp
setfacl -R -d -m u:${HTTPDUSER}:rwx tmp
setfacl -R -m u:${HTTPDUSER}:rwx logs
setfacl -R -d -m u:${HTTPDUSER}:rwx logs
chmod +x bin/cake
php bin/cake.php
#提示信息
$ php bin/cake.php
Exception: Plugin DebugKit\Plugin could not be found. in [/var/www/my_php_cake/vendor/cakephp/cakephp/src/Core/PluginCollection.php, line 127]
composer require cakephp/debug_kit
$ composer require cakephp/debug_kit
Using version ^3.18 for cakephp/debug_kit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
^C
jinbo@jinbo-Latitude-E5440:/var/www/my_php_cake$ composer require cakephp/debug_kit --prefer-dist
Using version ^3.18 for cakephp/debug_kit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
^C
jinbo@jinbo-Latitude-E5440:/var/www/my_php_cake$ composer require cakephp/debug_kit
Using version ^3.18 for cakephp/debug_kit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 59 installs, 0 updates, 0 removals
- Installing jdorn/sql-formatter (v1.2.17): Downloading (100%)
- Installing symfony/process (v4.2.8): Downloading (100%)
- Installing symfony/finder (v4.2.8): Downloading (100%)
- Installing seld/phar-utils (1.0.1): Downloading (100%)
- Installing seld/jsonlint (1.7.1): Downloading (100%)
- Installing justinrainbow/json-schema (5.2.8): Downloading (100%)
- Installing composer/xdebug-handler (1.3.2): Downloading (100%)
- Installing composer/spdx-licenses (1.5.1): Downloading (100%)
- Installing composer/semver (1.5.0): Downloading (100%)
- Installing composer/ca-bundle (1.1.4): Downloading (100%)
- Installing composer/composer (1.8.5): Downloading (100%)
- Installing cakephp/debug_kit (3.18.0): Downloading (100%)
- Installing twig/twig (v1.41.0): Downloading (100%)
- Installing umpirsky/twig-php-function (v0.1): Downloading (100%)
- Installing jasny/twig-extensions (v1.2.0): Downloading (100%)
- Installing asm89/twig-cache-extension (1.3.2): Downloading (100%)
- Installing aptoma/twig-markdown (2.0.0): Downloading (100%)
- Installing ajgl/breakpoint-twig-extension (0.3.4): Downloading (100%)
- Installing wyrihaximus/twig-view (4.3.8): Downloading (100%)
- Installing cakephp/bake (1.9.6): Downloading (100%)
- Installing squizlabs/php_codesniffer (3.4.2): Downloading (100%)
- Installing cakephp/cakephp-codesniffer (3.1.1): Downloading (100%)
- Installing m1/env (2.1.2): Downloading (100%)
- Installing josegonzalez/dotenv (3.2.0): Downloading (100%)
- Installing sebastian/version (2.0.1): Downloading (100%)
- Installing sebastian/resource-operations (1.0.0): Downloading (100%)
- Installing sebastian/recursion-context (3.0.0): Downloading (100%)
- Installing sebastian/object-reflector (1.1.1): Downloading (100%)
- Installing sebastian/object-enumerator (3.0.3): Downloading (100%)
- Installing sebastian/global-state (2.0.0): Downloading (100%)
- Installing sebastian/exporter (3.1.0): Downloading (100%)
- Installing sebastian/environment (3.1.0): Downloading (100%)
- Installing sebastian/diff (2.0.1): Downloading (100%)
- Installing sebastian/comparator (2.1.3): Downloading (100%)
- Installing phpunit/php-text-template (1.2.1): Downloading (100%)
- Installing doctrine/instantiator (1.2.0): Downloading (100%)
- Installing phpunit/phpunit-mock-objects (5.0.10): Downloading (100%)
- Installing phpunit/php-timer (1.0.9): Downloading (100%)
- Installing phpunit/php-file-iterator (1.4.5): Downloading (100%)
- Installing theseer/tokenizer (1.1.2): Downloading (100%)
- Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%)
- Installing phpunit/php-token-stream (2.0.2): Downloading (100%)
- Installing phpunit/php-code-coverage (5.3.2): Downloading (100%)
- Installing webmozart/assert (1.4.0): Downloading (100%)
- Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%)
- Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)
- Installing phpdocumentor/reflection-docblock (4.3.1): Downloading (100%)
- Installing phpspec/prophecy (1.8.0): Downloading (100%)
- Installing phar-io/version (1.0.1): Downloading (100%)
- Installing phar-io/manifest (1.0.1): Downloading (100%)
- Installing myclabs/deep-copy (1.9.1): Downloading (100%)
- Installing phpunit/phpunit (6.5.14): Downloading (100%)
- Installing jakub-onderka/php-console-color (v0.2): Downloading (100%)
- Installing jakub-onderka/php-console-highlighter (v0.4): Downloading (100%)
- Installing dnoegel/php-xdg-base-dir (0.1): Downloading (100%)
- Installing nikic/php-parser (v4.2.1): Downloading (100%)
- Installing symfony/polyfill-php72 (v1.11.0): Downloading (100%)
- Installing symfony/var-dumper (v4.2.8): Downloading (100%)
- Installing psy/psysh (v0.9.9): Downloading (100%)
cakephp/debug_kit suggests installing ext-pdo_sqlite (DebugKit needs to store panel data in a database. SQLite is simple and easy to use.)
asm89/twig-cache-extension suggests installing psr/cache-implementation (To make use of PSR-6 cache implementation via PsrCacheAdapter.)
aptoma/twig-markdown suggests installing michelf/php-markdown (Original Markdown engine with MarkdownExtra.)
aptoma/twig-markdown suggests installing knplabs/github-api (Needed for using GitHub's Markdown engine provided through their API.)
ajgl/breakpoint-twig-extension suggests installing ext-xdebug (The Xdebug extension is required for the breakpoint to work)
ajgl/breakpoint-twig-extension suggests installing symfony/framework-bundle (The framework bundle to integrate the extension into Symfony)
ajgl/breakpoint-twig-extension suggests installing symfony/twig-bundle (The twig bundle to integrate the extension into Symfony)
m1/env suggests installing m1/vars (For loading of configs)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.5)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
php bin/cake.php
No command provided. Choose one of the available commands.
Current Paths:
* app: src/
* root: /var/www/my_php_cake/
* core: /var/www/my_php_cake/vendor/cakephp/cakephp/
Available Commands:
- bake
- benchmark
- cache
- compile
- completion
- console
- whitespace
- help
- i18n
- migrations
- orm_cache
- plugin
- routes
- schema_cache
- server
- version
To run a command, type `cake command_name [args|options]`
To get help on a specific command, type `cake command_name --help`
$ bin/cake server
Welcome to CakePHP v3.7.7 Console
---------------------------------------------------------------
App : src
Path: /var/www/my_php_cake/src/
DocumentRoot: /var/www/my_php_cake/webroot
Ini Path:
---------------------------------------------------------------
built-in server is running in http://localhost:8765/
You can exit with `CTRL-C`
[Fri May 17 16:18:11 2019] 127.0.0.1:38072 [200]: /css/base.css
[Fri May 17 16:18:11 2019] 127.0.0.1:38076 [200]: /css/style.css
[Fri May 17 16:18:11 2019] 127.0.0.1:38080 [200]: /css/home.css
[Fri May 17 16:18:11 2019] 127.0.0.1:38084 [200]: /img/cake.logo.svg
[Fri May 17 16:18:11 2019] 127.0.0.1:38090 [200]: /font/cakedingbats-webfont.woff2
[Fri May 17 16:18:12 2019] 127.0.0.1:38096 [200]: /favicon.ico
$ cat cakephp.conf
server {
charset UTF-8;
listen 80;
#listen 443 ssl;
server_name cake.php.com;
if ( $http_cookie ~* "(.*)$") {
set $qcookie $1;
}
root /var/www/my_php_cake/webroot;
index index.php;
access_log /var/www/my_php_cake/logs/access.log;
error_log /var/www/my_php_cake/logs/error.log;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
if ( $fastcgi_script_name ~ \..*\/.*php ) {
return 403;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
127.0.0.1 cake.php.com
成功的出现了上边的截图
https://book.cakephp.org/3.0/en/installation.html
https://pkg.phpcomposer.com/
https://docs.phpcomposer.com/03-cli.html