ThinkPHP 6.0 Update: Core & ORM Enhancements, PHP 8.5 Compatibility
The ThinkPHP 6.0 release brings extensive core and ORM improvements—including Config, routing, request/response, Redis caching, lazy collections, view model lifecycle, and query enhancements—adds new CLI tools, ensures full PHP 8.5 compatibility, and provides detailed upgrade instructions and migration notes.
Core Update
Core Feature Enhancements
Config class optimization
Improved hook method with key‑parameter support
Adjusted lazy method implementation to boost configuration loading efficiency
Routing system improvements
Fixed URL generation logic
Added namespace‑bound controller suffix support
Enhanced URL validity checks for route groups
Optimized middleware parameter passing
Request/Response optimizations
Extended Request class capabilities
Enhanced exception handling in Response::send
Improved HttpEnd error logging
Compatibility & Performance
PHP compatibility
Full support for PHP 8.5
Adjusted psr/http-message dependency to allow ^2.0 Cache and logging
Improved Redis cache driver performance
Optimized log file deletion order and processing efficiency
Development Tool Enhancements
New CLI command
Added optimize command offering additional optimization options
Code quality
Refined PHP CS Fixer configuration rules for better code standards and maintainability
ORM Update
ThinkORM 4.0 receives a large set of optimizations and improvements.
Performance Optimizations
Introduced LazyCollection for lazy data sets, dramatically reducing memory usage
Rewrote chunk to use lazy, improving large‑data handling performance
Added cursor for association pre‑load queries, cutting memory overhead
Enhanced handling of distinct in lazy method
Extended toArray with append supporting relation.attr Optimized JSON field parsing efficiency
Added page method to LazyCollection for simplified data processing
Enabled cursor method to support association queries
Improved limit for view model pre‑load queries
Enhanced
PDOConnection queryand execute methods to operate without relying on Query
View Model Enhancements
Full lifecycle support (query, validate, write) for view models
Automatic association query and write support
Independent query scopes and searchers
JSON field mapping and type conversion
Added update and create methods returning the current view model
New methods: clear, reflesh, validate, data Write operations disabled when readonly is true (deprecating allowWrite)
Auto‑mapping detection replaces reliance on autoMapping definition
Automatic query condition handling based on view model attributes
Support for mapping query sort fields
Improved multi‑level sub‑association mapping and nested association writes
Enhanced getter invocation and base‑class parameter definitions
Extended data method to accept original attributes and incoming objects
Added validation mapping configuration
validate_mapping_dataDatabase Connection Enhancements
connectnow accepts array configuration
Database drivers gain unified timezone parameter
PostgreSQL driver refined to use system tables for field metadata pgsql driver can retrieve field annotation content
Added after_connect event hook
Treat numberic type as string
Association Query Improvements
One‑to‑many associations now support first and last methods
One‑to‑one associations now support firstOfMany and lastOfMany Enhanced hasWhere to accept richer array syntax
Association writes now support JSON field mapping
Fixed belongsTo interaction with
hasWhereModel Feature Enhancements
Added scene method for automatic validation scenes
Introduced getBaseOptions() for base configuration definitions
New attribute setters/getters: setAttrs, getAutoInc Improved suffix handling getPk now works with tables lacking a primary key
Added toView conversion method
Refined autoWriteData to skip auto‑writing timestamps when manually set
Extended destory with together parameter
Enhanced magic methods __isset, __unset, __unserialize Removed automatic increment handling from autoinc Improved newInstance and setModel for entity and view models
Updated clone and refresh for view models
Automatic query field recognition improvements
Query Function Improvements
Added lazy query method lazy Optimized pre‑load association usage with lazy Introduced streaming method stream with callback support
Enhanced hasWhere to accept more array patterns
Improved repeated calls to join queries parserOrder now supports JSON field sorting getOrigin gains type‑conversion parameter
Bug Fixes
Fixed DateTime formatting issue, now allows null writes
Corrected soft‑delete behavior
Resolved chunk primary‑key‑missing query error
Adjusted default parameters of OptimLock getDbWhere Fixed alias handling in order when passing arrays
Repaired chunk query interruption problem
Fixed Mongo cursor query issue
Corrected data parameter handling in modifiers
Improved update method data refresh behavior
Installation & Upgrade
Fresh Installation
composer create-project topthink/think tpUpgrade Existing Project
composer update topthink/frameworkImportant Notes
This release is a regular maintenance version and remains backward compatible.
Test in a staging environment before deploying to production.
For any issues, consult the official documentation or submit an Issue.
Acknowledgements
Thanks to all contributors who helped improve ThinkPHP. The framework continues to evolve with a focus on simplifying development.
Official resources:
Website: https://www.thinkphp.cn
GitHub repository: https://github.com/top-think/framework
Documentation: https://doc.thinkphp.cn
Community forum: https://bbs.thinkphp.cn
Official chatbot: https://chat.topthink.com
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
