CakePHP : Install2024/01/30 |
Install CakePHP which is a PHP Web application framework. |
|
[1] | Install PHP Composer and other modules first. |
root@dlp:~ # pkg install -y php83-composer php83-curl php83-session php83-tokenizer php83-xml php83-xmlwriter php83-dom php83-fileinfo php83-gd php83-pdo php83-simplexml php83-pear-PHP_CodeSniffer |
[2] | Create a CakePHP test project with a common user. |
freebsd@dlp:~ $
mkdir test-project2 freebsd@dlp:~ $ cd test-project2
# create [my-app] CakePHP project freebsd@dlp:~/test-project2 $ composer create-project cakephp/app my-app Creating a "cakephp/app" project at "./my-app" Installing cakephp/app (5.0.1) - Installing cakephp/app (5.0.1): Extracting archive Created project in /home/freebsd/test-project2/my-app Loading composer repositories with package information Updating dependencies Lock file operations: 86 installs, 0 updates, 0 removals ..... ..... Created `config/app_local.php` file Created `/home/freebsd/test-project2/my-app/logs` directory Created `/home/freebsd/test-project2/my-app/tmp/cache/views` directory Set Folder Permissions ? (Default to Y) [Y,n]? y Permissions set on /home/freebsd/test-project2/my-app/tmp/cache Permissions set on /home/freebsd/test-project2/my-app/tmp/cache/models Permissions set on /home/freebsd/test-project2/my-app/tmp/cache/persistent Permissions set on /home/freebsd/test-project2/my-app/tmp/cache/views Permissions set on /home/freebsd/test-project2/my-app/tmp/sessions Permissions set on /home/freebsd/test-project2/my-app/tmp/tests Permissions set on /home/freebsd/test-project2/my-app/tmp Permissions set on /home/freebsd/test-project2/my-app/logs Updated Security.salt value in config/app_local.phpfreebsd@dlp:~/test-project2 $ cd my-app freebsd@dlp:~/test-project2/my-app $ ./bin/cake server -H 0.0.0.0 -p 8765 Welcome to CakePHP v5.0.5 Console ------------------------------------------------------------------------------- App : src Path: /home/freebsd/test-project2/my-app/src/ DocumentRoot: /home/freebsd/test-project2/my-app/webroot Ini Path: ------------------------------------------------------------------------------- built-in server is running in http://0.0.0.0:8765/ You can exit with `CTRL-C` [Tue Jan 30 13:42:46 2024] PHP 8.3.1 Development Server (http://0.0.0.0:8765) started |
Access to the URL you set from any client computer, and then that's OK if following site is shown. |
[3] | Create a sample Hello World app. |
freebsd@dlp:~ $
cd ~/test-project2/my-app
freebsd@dlp:~/test-project2/my-app $
vi src/Controller/HelloWorldController.php # create new <?php namespace App\Controller; class HelloWorldController extends AppController { public function index() { } }
freebsd@dlp:~/test-project2/my-app $
mkdir templates/HelloWorld freebsd@dlp:~/test-project2/my-app $ vi templates/HelloWorld/index.php # create index <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Hello World</title> </head> <body> <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;"> Hello CakePHP World! </div> </body> </html> ./bin/cake server -H 0.0.0.0 -p 8765 |
Sponsored Link |