Skip to content

Cleaner file structure #913

@jtojnar

Description

@jtojnar

The existing structure is unnecessarily complicated:

  1. The different source files are intermingled with the rest, all the source directories have to be set for each tool manually.
  2. There are some directories that need to be accessible from the HTTP server but they are again located in different places (public and data).
  3. There are directories that need to be writeable and not accessible.

Goals

  1. Related files and directories should be grouped together.
  2. Files that should not be accessible should not be grouped with public ones.
  3. Configuring web server should be simple – there should not be any complicated rewrite rules so that selfoss could be installed on non-traditional servers without much work.
  4. Installation should be simple (chmoding as few directories as possible).

Proposed directory structure

  • 📂 data (writeable)
    • 📁 cache
    • 📁 logs
    • 📁 sqlite
    • 📄 config.ini
  • 📁 plugins
  • 📂 public (accessible)
    • 📂 assets
      • 📁 css
      • 📁 fonts
      • 📁 images
      • 📁 js
      • 📄 favicon.svg
    • 📂 gen (writeable)
      • 📁 favicons
      • 📁 thumbnails
      • 📄 all.css
      • 📄 all.js
  • 📂 src
    • 📁 controllers
    • 📁 daos
    • 📁 helpers
    • 📁 lang
    • 📁 spouts
    • 📁 templates
    • 📄 common.php
  • 📁 tests
  • 📁 utils
  • 📁 vendor
  • 📄 .htaccess
  • 📄 index.php
  • 📄 README.md
  • 📄 run.php

The public directory can either be set as document root of virtual host or there can be a simple .htaccess in the parent directory.

Further goals to consider

  • Automated installer should be able to write config.ini, data is thus a good location for it.
  • I would like to split selfoss-client off of selfoss. That would mean selfoss would drop the templates and assets directories, only keeping the API, favicons and thumbnails.
  • Maybe selfoss could be compiled to PHAR to reduce the number of files (faster upload to FTP). At least the public and data directories would need to be kept outside.
  • If we created a plugin manager as a part of selfoss, it would need to be able to write to plugins directory.
  • There should be a place for tests, it should be easily separable from the source code so it could be excluded in the build.

Simpler .htaccess

<IfModule mod_rewrite.c>
	RewriteEngine On
	# RewriteBase /

	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
</IfModule>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions