ThinkPHP学习笔记(一)环境搭建和遇到的有关问题
ThinkPHP学习笔记(一)环境搭建和遇到的问题
index.php
<?php /** * A alpha 内部测试阶段 * B beta 公开测试 * C RC 进行了重要bug的修复 * F final 正式版本 * * 模板解析,建议使用thinkphp的模板 * * 使用 * 1.拷贝到项目中 * 2.编写一个php将 * ini_set("session.save_handler", "files"); * define("THINK_PATH", "./ThinkPHP/"); * define("APP_PATH", "./home/"); * define("APP_NAME", "home"); * * require THINK_PATH.'ThinkPHP.php'; * * App::run(); * 3.运行后生成home创建的文件夹存放的内容 * lib: * home/lib/Action目录将所有的控制器都放在Action里面 * home/lib/Model将所有的模型(自定义数据库类)放在Model目录下 * 在home/lib/org目录是指扩展的类,可以将thinkphp核心目录下的扩展org文件夹拿过来,也可以自己写一些扩展类 * Runtime: * Cache:编译后的文件存放的目录 * Data:与表相关的全部数据存放位置 * Logs:日志文件存放位置 * Temp:文件换成 * Tpl(每创建一个文件夹就是一个皮肤模板) * defult:默认模板 * 4.命名规则: * Action:XxxxAction.class.php * Model:存在xxxx表,那么必须写XxxxModel.class.php * * 问题 * 1.Multiple annotations found at this line:- Occurrence of 'getAll()' * 数据库Driver文件夹中的所有类的getAll方法将private换成public即可 * 2.session_start(): Failed to initialize storage module * 搭建ThinkPHP环境出现的问题 * 解决方法有两种如下: * 2.1.在报错的文件里的session start();之前加入如下代码:ini_set(‘session.save_handler’, ‘files’); 。这种方法适合租用空间的用户使用。 * 2.2.在php.ini文件里,显式指定session的save_path(比如 c:/temp)然后重启web服务。如果服务器的管理权限属于你,那还是这样改比较方便。 * 原因分析:php5一个安全模式的bug,默认session的save_path是系统的临时目录,这样会要校验权限。 * * Fatal error: session_start(): Failed to initialize storage module: user (path: /tmp) in /home/***.php on line 1 * 从错误看来是系统临时目录/tmp无法保存session文件的问题, * 原则上我们可以直接修改php.ini中的session.save_handler值从’user’到’files’。但是在虚拟空间里通常都没有修改权限。这是我的解决办法: * if(!is_dir(’./tmp/’))mkdir (’./tmp/’, 0700); * session_save_path(’./tmp/’); * session_start(); * 直接在session_start前面增加上面的内容。 * 或者打开php.ini中的seession.path指定有权限的路径。 */ini_set("session.save_handler", "files");define("THINK_PATH", "./ThinkPHP/");define("APP_PATH", "./home/");define("APP_NAME", "home");require THINK_PATH.'ThinkPHP.php';App::run();?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Session failure is usually caused by the session lifetime expiration or server shutdown. The solutions: 1. Extend the lifetime of the session; 2. Use persistent storage; 3. Use cookies; 4. Update the session asynchronously; 5. Use session management middleware.

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

How to set the PATH environment variable in Linux systems In Linux systems, the PATH environment variable is used to specify the path where the system searches for executable files on the command line. Correctly setting the PATH environment variable allows us to execute system commands and custom commands at any location. This article will introduce how to set the PATH environment variable in a Linux system and provide detailed code examples. View the current PATH environment variable. Execute the following command in the terminal to view the current PATH environment variable: echo$P

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Solution to the cross-domain problem of PHPSession In the development of front-end and back-end separation, cross-domain requests have become the norm. When dealing with cross-domain issues, we usually involve the use and management of sessions. However, due to browser origin policy restrictions, sessions cannot be shared by default across domains. In order to solve this problem, we need to use some techniques and methods to achieve cross-domain sharing of sessions. 1. The most common use of cookies to share sessions across domains

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.
