1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

オリジナルCMSの開発日記 #1

Posted at

あーWordPressって高機能で良いんだけど、使いこなせないしあと重たい...
しかも個人開発のCMSは学習目的で作られていたりするから、自分のニーズに合わないことが多いんだよなぁ...

じゃあ、自分で作ればいいじゃん?

ということで現在制作中

今年の3月ごろ、そんなことを思い立ってから現在制作中なんですが、
作業の様子とか進捗を見せながら進めるほうが良いと思ったので、こういう日記風にしました。

Qiitaに書くことで、誰かの目印になったり、
「こんなCMSが欲しかった」と思ってくれれば嬉しいです。

今回作るもの

ここに特徴などが載っています。
オープンソースでGitHub上に公開する予定です。

まずは LICENSE ファイルを作成

MIT License

Copyright (c) 2025 yu-.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

このライセンスを使うことで、利用者は自己責任で使えるようになります。
開発者としては、自由に公開しつつ、
法的なリスクを最小限に抑えられるのがポイントです!

次に.htaccessを作成

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ mode.php?path=$1 [L,QSA,B]

この設定の目的は、URLの見た目を整えつつ、内部的には mode.php に処理を渡すことなんです。

  • どう動くのか?
    http://localhost/ にアクセスすると、通常通り index.php や index.html が表示される
    http://localhost/hoge にアクセスすると、実際には mode.php?path=hoge が呼び出され、hoge に対応する処理が実行される

WordPressにも似たような .htaccess の仕組みがあります。 実際、WordPressでは「パーマリンク設定」によってURLを整え、内部では index.php にルーティングされるようになっています。

あとは index.php と mode.php を作成

<?php
require("src/function.php");

こんなシンプルな内容を書いたら、今回の作業は終了です。


次回の内容は、Discordサーバーにて発表する予定です~
入っていない方は、是非入っていただけると嬉しいです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?