artoodetoo/so-example
Composer 安装命令:
composer create-project artoodetoo/so-example
包简介
StackOverflow DB for Laravel
README 文档
README
StackOverflow DB for Laravel
Introduction and Disclaimer
It won't be a S.O. clone in any meaning. My interest is to get big enough and close-to-real-world DB sandbox. And get it ready to Laravel Eloquent.
To be precise, it is the common structure of a several Q-n-A sites of StackExchange, not only stackeoverflow.com.
Please start from the awesome Brent Ozar post to get more information about the topic.
Original DB is in MS SQL and dump is available in XML. Database has obfuscated private information and it's publicly available under cc-by-sa license.
My humble goal is MySQL database in Laravel standards.
It will be a set of migrations, classes and console command to import DB dump and fill the gaps when required.
Since it is a one time action, I DON'T try to do import as fast as possible. I know, SQL can be much more effective than cycles on the PHP side. But that is.
NOTE:
As of v0.1, the tables do not have indexes and foreign keys. It allows to import data fast but the queries are slow.
Starting from v0.2, I have been working on data consistency and queries optimization, so there will be indexes and FKs in migrations.Feel free to run
git reset <tagname> --hardorgit pullto get this or that set of migrations before the import.
Laravelization
Now all names are in snake_case.
It is common to use created_at and updated_at names for timestamps, so I replaced original field names to these ones when applicable.
As for users table, I make it compatible with standard Laravel auth, so I added some fields.
I shorted a couple of super long names like PostHistoryTypeId => history_type_id.
To use unsigned big integer for primary and foreign keys, I have replaced special value of "-1" to "1".
Missing data
For privacy purposes, some fields are not mentioned in the dump. But they obviously required, like email and password. See my notes about users above.
Votes table miss the voting user reference. It is null in most cases (exceptions are bounties and favs), it looks pretty unreal and have to be filled by fake data.
Posts and Tags should be related as many-to-many. The pivot table is missing and the only source is denormalized field posts.tags.
Usage
Installation
composer create-project artoodetoo/so-structure
Then go to new project directory, set database parameters in the .env file and run
php artisan migrate
to create all the tables.
Data Import and post-processing
Download database dump from Web Archive site or via torrent. (you can find links in Brent's article)
Import tables content one by one:
php artisan stack:import path/to/Table.xml
Typically, for each site you have 8 files or tables to import:
Users, Badges, Tags, Posts, Comments, Votes, PostLinks, PostHistory.
The 9th table post_tag does not come out of the box. To recreate its data you have to run
php artisan stack:post-tag
Votes in the dump are anonymous. The only exception is favorite and bounty actions.
To attach acceptance and up/down votes to random users, call
php artisan stack:vote-users --action=accept php artisan stack:vote-users --action=up-down
(These are very slow)
License
StackOverflow DB for Laravel is open-sourced software licensed under the MIT license.
artoodetoo/so-example 适用场景与选型建议
artoodetoo/so-example 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 5, 最近一次更新时间为 2020 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「project」 「laravel」 「stackoverflow」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 artoodetoo/so-example 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 artoodetoo/so-example 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 artoodetoo/so-example 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Flat URLs (like Stack Overflow) for TYPO3
Library to validate and parse social media profile URLs
Task system for APPUI
An introduction to machine learning in Rubix ML using the famous Iris dataset and the K Nearest Neighbors classifier.
Alfabank REST API integration
The Stack Exchange OAuth 2.0 Client Provider for The PHP League OAuth2-Client
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-15