PHP Framework for Learning

Preparation

2017-11-25 release

2021-01-13 update


English sample code

Perfect PHP is a highly evaluated PHP Book in Japan.
The sample code in book is a Framework for Learning. (Author: Katsuhiro Ogawa)
Framework for learning consists of Framework and Mini Blog Application.
It was made in 2010, but it is useful enough even at the present time (2021).
I translated the sample code from Japanese to English.
If you have 'sample code', 'this site', 'IDE debugging', The book is not necessary.
It is a wonderful Framework for Learning, so I want people all over the world to use it.

English sample code
https://github.com/beginner001-etc/php-framework-for-learning

php-framework-for-learning-master.zip
decompress php-framework-for-learning-master.zip
rename folder name from php-framework-for-learning-master to mini-blog.localhost
copy mini-blog.localhost to C:\xampp\htdocs or
copy mini-blog.localhost to C:\XAMPP\xampp_5.6.31\htdocs See Other | XAMPP

Framework for learning mini-blog.localhost
Framework core
web
bootstrap.php
Mini Blog Application (controllers)
(models)
(views)
MiniBlogApplication.php

Root directory

C:\XAMPP\xampp_5.6.31\htdocs
  mini-blog.localhost
    controllers
    core
    models
    views
    web
    bootstrap.php
    MiniBlogApplication.php

Operating environment

  • XAMPP 5.6.31 (Apache 2.4.26, MariaDB 10.1.25, PHP 5.6.31)
  •   XAMPP Installation Destination : any Folder (e.g. C:\XAMPP\xampp_5.6.31) See Other | XAMPP
  • IDE (NetBeans IDE 8.2) See Other | Xdebug, NetBeans

See Other | Environment setting procedurepoint

Document Root

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/XAMPP/xampp_5.6.31/htdocs"
    DirectoryIndex index.php index.html

    <Directory "C:/XAMPP/xampp_5.6.31/htdocs">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName mini-blog.localhost
    DocumentRoot "C:/XAMPP/xampp_5.6.31/htdocs/mini-blog.localhost/web"
    DirectoryIndex index.php index.html

    <Directory "C:/XAMPP/xampp_5.6.31/htdocs/mini-blog.localhost">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

C:\XAMPP\xampp_5.6.31\apache\conf\extra\httpd-vhosts.conf

hosts Domain

127.0.0.1 localhost
127.0.0.1 mini-blog.localhost

C:\Windows\System32\drivers\etc\hosts

Database

C:\XAMPP\xampp_5.6.31\xampp-control.exe (Apache, MySQL)
http://localhost/phpmyadmin/ (URL)

create Database mini_blog (phpMyAdmin)
create table SQL create_table.sql (phpMyAdmin, select SQL TAB on mini_blog)
restore table SQL restore_table.sql (phpMyAdmin, select SQL TAB on mini_blog)
(if there is an error) IMPORTANT! Enable foreign key checks: OFF
restore table SQL (Enable foreign key checks: OFF)

Test Data

restore_table.sql (above Database)


user table
id user_name password created_at
1 user1 ee5281d035bd1bd7786301be4274a68b006ae916 2017-11-01 00:00:00
2 user2 ee5281d035bd1bd7786301be4274a68b006ae916 2017-11-01 00:00:00
3 user3 ee5281d035bd1bd7786301be4274a68b006ae916 2017-11-01 00:00:00

ee5281d035bd1bd7786301be4274a68b006ae916 = String 'password' is hashed
Login User ID: user1Password: password

status table
id user_id body created_at
1 1 status1 user1 test1 2017-11-01 00:00:00
2 1 status2 user1 test2 2017-11-01 00:00:00
3 2 status3 user2 test3 2017-11-01 00:00:00
4 2 status4 user2 test4 2017-11-01 00:00:00
5 3 status5 user3 test5 2017-11-01 00:00:00
following table
user_id following_id
1 2

If following table is empty,
Login as user1, You input http://mini-blog.localhost/user/user2 in URL, user2 Contribution list is displayed.
Click 'Follow' button to create the above data.

Operation Check

http://mini-blog.localhost/ (URL)



Login screen
  Login User ID: user1, Password: password.
Homepage

Page Top
Page Bottom