The old versions of JavaScript had no import, include, or require, so many different approaches to this problem have been developed. But since 2015 (ES6), JavaScript has had the ES6 modules standard to import modules in Node.js, which is also supported by most modern browsers. For compatibility with older browsers, build tools like Webpack and Rollup and/or transpilation tools like Babel can be used. […]
Category: Dev
Post about being an IT developer,including programming, career path, and management.
Apache的重定向和伪静态
重定向和伪静态的基本原理和方法 重定向和伪静态的实现方法: 通过.htaccess配置 工作原理: .htaccess文件提供了针对每个目录改变配置的方法。在指定目录中,放置一个.htaccess文件,此文件的作用域实用于当前目录及其所有的子目录。 性能问题: 开启页面的时候要查找所有的上级目录的.htaccess。 例如:/wamp/www/project1/public 文件夹下有.htaccess文件,那么Apache会查找: /wamp/www/project1, /wamp/www, /wamp, / 文件夹下是否有.htaccess。 建议PROD以下的环境,使用.htaccess,生产环境需要把所有的重定向文件写到Apache主配置文件中。 安全问题:允许用户自行修改服务器的配置,且在不需要重启apache的情况下生效。例如,在没有index文件的情况下,很有可能会暴露文件夹下的所有文件。 妥协: 共享服务器,访问量不够大的网站,需要更好的SEO效果的网站,可以妥协掉部分性能。 通过Apache的主配置文件字段 使用PHP等脚本文件实现(仅限外部重定向) 一个基本实例: 开启目录重定向的权限: AllowOverride All 配合 .htaccess 配合调试,不需要重启服务器。在Windows下,用CMD创建.htaccess命令:echo 1 > .htaccess RewriteEngine on 开启mod_rewrite RewriteRule ^(.*)\.htm$ $1.html 当浏览器的URL尝试访问test.htm,Apache会在此.htaccess文件的当前目录下寻找test.html文件。 Apache重定向原理: https://httpd.apache.org/docs/2.4/images/rewrite_process_uri.png 防止出现死循环。 mod_rewrite 详解 1. 日志功能 LogLevel Apache 2.4+ RewriteLog RewriteLogLevel Apache 2.2 配置:LogLevel alert rewrite:trace8 (LogLevel 不要大于trace2,或者关闭。) 只能在Apache的主配置文件下配置,无法在.htaccess进行配置。 查看:apache_error.log 文件 2. RewriteRule语法 基本格式:RewriteRule 模式(正则匹配) 替换的URL [flags] 模式匹配,支持Perl格式的正则表达式。 rewrite的预设变量和替换模式的匹配结果: $1 多个flag用逗号隔开:[R=302,C] R flag […]
Laravel Domain Driven: Application Layer
An application’s goal is to get some kind of input, transform it for use in the domain layer, and represent the output to the user or store it somewhere.
Laravel Domain Driven: Domain Layer
“Human think in categories, our code should be a reflection of that”. Recently I’ve read an awesome e-book about Laravel DDD. It refreshed me a lot memories in the past. And also I’ve got new learnings.
Some Good SQL Habbits
Just sharing some good SQL habbits I’m doing at my daily work.
Code Review Checklist
My checklist to review the code more carefully at my daily work.