惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
Martin Fowler
Martin Fowler
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
U
Unit 42
B
Blog RSS Feed
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
腾讯CDC
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
博客园 - 聂微东
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
Engineering at Meta
Engineering at Meta

博客园 - tying

fastadmin mongodb 处理及使用 mysql的知识扩展 <论语> fastadmin配合宝塔面板造成cors error 跨域问题 一个小并发,引起的数据错误 小型在线聊天功能 fastadmin数据库操作 技术文章分享 shopxo学习过程 fastadmin 開發好文章 fastadmin常用前端组件 2024-11-13关于监管特殊停牌炒作股票事件--兼此事件复盘 深入浅出的讲解mysql优化 关于gruop by,where和order by ,以及一些mysql的探讨 fastadmin使用感受 fastadmin命令行模式--command mac 下Fastadmin 框架搭建 Mac电脑php环境搭建 关于php+mysql性能在实际工作中的应用实例 yii2的单元测试
d8的入口文件及引申
tying · 2018-10-16 · via 博客园 - tying

d8入口文件

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<?php

/**

 * @file

 * The PHP page that serves all page requests on a Drupal installation.

 *

 * All Drupal code is released under the GNU General Public License.

 * See <a href="/project/copyright" class="alinks-link" title="模块介绍:可以设定网站整体和单篇内容的著作权/授权声明。管理者可以设定可选用的著作权种类,呈现在区块或页尾里。手册页面(Book)可以选择性地设定所有子页面为同一著作权声明,并让每一份手册或区域有其自己的著作权声明。">COPYRIGHT</a>.txt and LICENSE.txt files in the "core" directory.

 */

use Drupal\Core\DrupalKernel;

use Symfony\Component\HttpFoundation\Request;

$autoloader = require_once 'autoload.php';

$kernel = new DrupalKernel('prod', $autoloader);

$request = Request::createFromGlobals();

$response = $kernel->handle($request);

$response->send();

$kernel->terminate($request, $response);

这一整套流程其实就是Symfony的运行机制

当然为了更好的了解这个运行过程,从网上找了个图片下

其实这里可以用自己的理解方式来理解上述问题,我做了如下方式,当然这只是粗糙的思路,并不是完美的代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

$request = ['http'=>$_SEVER,'params'=>$_GET,'params'=>$_POST] ;

$getrouter = $request['路由'];

$allrouter = ['router1'=>'file/class/action','路由2'=>'对应文件/对应类/对应方法'];

$router = separaterouter($allrouter['$getrouter']);

$file   = 'file';

$class  = 'class' ;

$action = 'action';

require_once($file);

$response = new $router.'()';

$page = $response->$action.'()';

echo $page;

watchdog($request,$response);

流程就到这里,下面来说说命名空间和autoload

熟悉这个的人就不用看了,5.3以前php的命名空间是不存在的,为啥后来有了

为了是区分两个相同类名,而不是同一个类的情况,比如在颜色的文件下有个green(绿色)类,定义了的色值、调色方法等,在姓氏里面定义了也green(格林)类,定义了历史、常用名等等。这两个在房屋装修中可能都会用到。

扯远了,回来继续

1

2

3

4

5

6

7

8

9

10

11

12

13

$autoloader = require_once 'autoload.php';

return require __DIR__ . '/vendor/autoload.php';

<?php

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInitDrupal8::getLoader();

composer这个工具大概的目的就是根据类名的及类的命名空间找到类文件所在位置,然后使用该类的时候自动加载这个类文件。相当于以前的require,只是变成自动的,当然它有自己的命名规范

想要了解的可以查看资料,之前找了一份,觉着挺好的,是个台湾人写的

http://blog.turn.tw/?p=1039