This publication describes a standard filesystem skeleton suitable for all PHP packages

Related tags

Frameworks skeleton
Overview

pds/skeleton

This publication describes a standard filesystem skeleton suitable for all PHP packages.

Please see https://github.com/php-pds/skeleton_research for background information.

Command-line tools for validating or generating PDS conform packages which are included with this standard are documented here.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this publication are to be interpreted as described in RFC 2119.

Summary

A package MUST use these names for these root-level directories:

If a package has a root-level directory for ... ... then it MUST be named:
command-line executables bin/
configuration files config/
documentation files docs/
web server files public/
other resource files resources/
PHP source code src/
test code tests/

A package MUST use these names for these root-level files:

If a package has a root-level file for ... ... then it MUST be named:
a log of changes between releases CHANGELOG(.*)
guidelines for contributors CONTRIBUTING(.*)
licensing information LICENSE(.*)
information about the package itself README(.*)

A package SHOULD include a root-level file indicating the licensing and copyright terms of the package contents.

Root-Level Directories

bin/

If the package provides a root-level directory for command-line executable files, it MUST be named bin/.

This publication does not otherwise define the structure and contents of the directory.

config/

If the package provides a root-level directory for configuration files, it MUST be named config/.

This publication does not otherwise define the structure and contents of the directory.

docs/

If the package provides a root-level directory for documentation files, it MUST be named docs/.

This publication does not otherwise define the structure and contents of the directory.

public/

If the package provides a root-level directory for web server files, it MUST be named public/.

This publication does not otherwise define the structure and contents of the directory.

N.b.: This directory MAY be intended as a web server document root. Alternatively, it MAY be that the files will be served dynamically via other code, copied or symlinked to the "real" document root, or otherwise managed so that they become publicly available on the web.

resources/

If the package provides a root-level directory for other resource files, it MUST be named resources/.

This publication does not otherwise define the structure and contents of the directory.

src/

If the package provides a root-level directory for PHP source code files, it MUST be named src/.

This publication does not otherwise define the structure and contents of the directory.

tests/

If the package provides a root-level directory for test files, it MUST be named tests/.

This publication does not otherwise define the structure and contents of the directory.

Other Directories

The package MAY contain other root-level directories for purposes not described by this publication.

This publication does not define the structure and contents of the other root-level directories.

Root-Level Files

CHANGELOG

If the package provides a root-level file with a list of changes since the last release or version, it MUST be named CHANGELOG.

It MAY have a lowercase filename extension indicating the file format.

This publication does not otherwise define the structure and contents of the file.

CONTRIBUTING

If the package provides a root-level file that describes how to contribute to the package, it MUST be named CONTRIBUTING.

It MAY have a lowercase filename extension indicating the file format.

This publication does not otherwise define the structure and contents of the file.

LICENSE

Whereas package consumers might be in violation of copyright law when copying unlicensed intellectual property, the package SHOULD include a root-level file indicating the licensing and copyright terms of the package contents.

If the package provides a root-level file indicating the licensing and copyright terms of the package contents, it MUST be named LICENSE.

It MAY have a lowercase filename extension indicating the file format.

This publication does not otherwise define the structure and contents of the file.

README

If the package provides a root-level file with information about the package itself, it MUST be named README.

It MAY have a lowercase filename extension indicating the file format.

This publication does not otherwise define the structure and contents of the file.

Other Files

The package MAY contain other root-level files for purposes not described in this publication.

This publication does not define the structure and contents of the other root-level files.

Comments
  • Tests dir won't work for some devs

    Tests dir won't work for some devs

    I know that PHPUnit is the most widely used testing suite out there, but I (and some others here and there) have made a conscious choice to use PHPSpec, which accomplishes basically the same thing but with a different (and in my opinion, better) grammar. It doesn't call it's code "tests" but rather "specs" to point out that what you write are specifications of what output is expected for certain input. And as such, in contrast to PHPUnit, it automatically uses a "specs" directory to hold that code. So because of that, none of my projects will have a "tests" directory.

    I would also mention Behat, which uses a "features" directory for its own set of reasons.

    Is there some way an allowance for this kind of thing could be worked into the standard?

    opened by garrettw 11
  • Package binaries MUST BE located in /bin

    Package binaries MUST BE located in /bin

    If a package provides a CLI, it's binary or binaries MUST BE located under the /bin directory and MUST BE configured as a vendor binary in the package its composer.json.

    opened by raphaelstolt 10
  • `vendor/` Directory Considerations

    `vendor/` Directory Considerations

    While libraries shouldn't commit the vendor directory to version control, there are instances where it might be beneficial for projects to commit the vendor directory.

    Open for discussion, consider revising the vendor/ section to read:

    The vendor/ directory MUST be reserved for use by package managers (e.g.: Composer).

    If the repository type is designated as a "project" in its composer.json file, the vendor/ directory SHOULD be ignored by revision control tools (e.g.: Git, Mercurial, Subversion, etc.). It SHOULD NOT be committed to revision control repositories.

    If the repository type is designated as a "library" (the default) or otherwise in its composer.json file, the vendor/ directory MUST be ignored by revision control tools (e.g.: Git, Mercurial, Subversion, etc.). It MUST NOT be committed to revision control repositories.

    This publication does not otherwise define the structure and contents of the directory.

    opened by ramsey 9
  • Templates / Views folder

    Templates / Views folder

    I know that not every application needs templates or views. So it shouldn't be a MUST. But I would prefer a suggestion how to name such a folder because I have seen so many different names in the wild.

    • view
    • views
    • templates
    • template
    • tpl
    • tpls
    • ...
    opened by RalfEggert 9
  • Build folder

    Build folder

    Wouldn't the quite popular build folder be a candidate for inclusion? I guess it didn't show up in the research data, as most projects only create it while building and delete it again afterwards.

    But nonetheless it is quite common in many build automation tools, continuous integration tools and projects like this one, for example.

    opened by ravage84 9
  • Encourage use of a LICENSE file

    Encourage use of a LICENSE file

    What about adding a SHOULD to the section about the LICENSE file? I know there are some companies out there that have legal departments that get heartburn over this kind of stuff, and encouraging people to explicitly state a license seems like a worthy endeavor.

    opened by jimbojsb 9
  • Resources folder

    Resources folder

    I'd like to propose the addition of the resources folder to this standard.

    The resources folder, to me at least, is a folder where one can store non public, non 100 % source code" related resource material/assets etc. For example, We used such a folder for storing vendor XML schema files for a XML API client library we recently developed.

    While I agree, it is not a very common folder, it is still a quite common enough one, as you can see by your own research data:

    • https://github.com/php-pds/skeleton_research/blob/1.x/results/01-dirs.txt#L4 Resources/ 5969
    • https://github.com/php-pds/skeleton_research/blob/1.x/results/01-dirs.txt#L22 resources/ 1424
    • https://github.com/php-pds/skeleton_research/blob/1.x/results/01-dirs.txt#L859 ressources/ 6
    • https://github.com/php-pds/skeleton_research/blob/1.x/results/01-dirs.txt#L937 Ressources/ 5
    • https://github.com/php-pds/skeleton_research/blob/1.x/results/01-dirs.txt#L328 resource/ 29
    • https://github.com/php-pds/skeleton_research/blob/1.x/results/01-dirs.txt#L401 Resource/ 21

    Total "resources" related: 7454

    Through your iteration steps, though, you only considered the resources variant with 1424 occurrences. https://github.com/php-pds/skeleton_research/blob/1.x/results/02-dirs.txt#L82

    This might be an addition for a later version of this standard, though.

    opened by ravage84 8
  • Public folder

    Public folder

    Hi @pmjones

    Thank you for your research and work on this.

    Personally, I'm a big proponent of such a minimalistic standard. I contributed to thephpleague/skeleton in the past and even setup a small skeleton for CakePHP 2.x Plugins.

    Since I support such an endeavor, I had a discussion about your standard with my team. They all support it, though it became clear, that the public folder was the only one that is kind of controversional.

    While I guess almost all of your proposed folders and files are already nearly de-facto standards or could become a standard without much of a fuzz, the public folder is the one where many devs will have a diverging opinon about.

    This could be because their framework simply demands them to put their public html stuff in a differently named folder or simply because of long time habits.

    Anyway, it would be really sad, if people can't adopt the standard, because they cannot adhere to your public folder requirement.

    And the way, how the draft is worded right now, it is a requirement:

    https://github.com/php-pds/skeleton#public

    If the package provides a directory for web server files, it MUST be named public/.

    That's why I really recommend you to not include the public folder with a MUST but wit a RECOMMENDED wording.

    This way, your standard gets adoption very easily.

    And if the PHP community settles on this matter in a nearby future, you can include the plugin folder with a MUST in a later version of the stardard.

    It's way easier to evolve a standard over time than trying to revolutionize with it.

    opened by ravage84 8
  • Encourage lean packages

    Encourage lean packages

    Release/dist packages MUST NOT contain repository meta data files like CONTRIBUTING , README, command-line executables related to the package its release process, and so on.

    See LeanPackageValidator for more details.

    opened by raphaelstolt 8
  • [Suggestion] Validate filesystem

    [Suggestion] Validate filesystem

    It would be useful to ship this package with a validator based on the recommendations. A simple compliance report would then be displayed to the user.

    I'm happy to help create this, if people agree to this feature.

    opened by afilina 7
  • Resource vs

    Resource vs "other files" and run-time generated artifacts

    I took a closer look at this standard and found one aspect of it to be lacking.

    I read the discussion about resources in #12 - I understand that it's common to have a folder named "resources", but I don't feel like the definition of it is meaningful.

    The term "resource" at the moment is is very broadly defined as:

    If the package provides a root-level directory for other resource files, it MUST be named resources/

    This is so broad it's almost conflicting with the description of "other directories":

    The package MAY contain other root-level directories for purposes not described by this publication.

    All I can surmise from these two descriptions is that "other files" may go either into "resources" or into "other directories".

    In other words, the description appears to indicate that I gather is probably true, that even if many projects have a folder named resources, the use of this folder is completely arbitrary - just the same as use of "other directories".

    So it's kind of already covered by "other directories", and there is no clear definition of what (if anything) should go into "resources", I think because the term "resource" is essentially every bit as broad as the term "file" - since the whole point of this standard is to help figure out how to structure the project's files/resources/assets/whatever, it seems more confusing than helpful to reserve a specific folder for "stuff", and at the same time have a clause that allows for any other root folder-name for "other stuff".

    Which brings me to the thing I didn't find as part of this specification.

    In our own internal folder-names specification for our projects, we have three reserved folders for "other files", but with a very important distinction, not regarding the type of files/resources that get put into those folders, but with a designated definition of the nature or origins of those "other files".

    In particular, I find that this proposed standard defines nothing with regards to dynamic files, so I will try to address that with the following suggestion.

    Not minding the folder-names we happen to use, and with attention to the folder-names and definitions already defined by this standard, I'd suggest the following:

    1. Change the definition of resources, such that this folder is reserved for permanent, static files - this could be scripts or other data-files under source-control, containing data-dependencies, which are loaded/parsed or otherwise required by the project.

    2. Add a reserved folder for run-time files, e.g. named runtime - this would be the designated root-folder for run-time generated artifacts, typically cache-files for computed data, images, log-files, temporary uploaded files, etc. This folder must be writable by the application, and all files should be considered volatile or transient, meaning you can erase the contents of this folder at any time without affecting the functionality of the application. (This is different from a system-defined "temp" folder, since e.g. log-files etc. could be important for diagnostic purposes, and since e.g. clearing the cache of a specific application may briefly affect the performance of that application.)

    3. Add a reserved folder for permanent assets, perhaps named assets (though this could be somewhat ambiguous with "web assets" such as CSS/JS files, so I'm definitely open to other ideas) - this would be the designated default root-folder for user-generated, permanent assets, such as uploaded images or other documents, and any other non-volatile data; resources that are critical to the functioning of the application and must not be erased.

    I'm merely spit-balling as far as the actual folder names here, just for the sake of discussion.

    I believe (2) and (3) are important because of things like:

    • folder-permissions - applications need write-access to these folders; because users need to know which folder is safe to clear when the application accumulates too much junk or when there's an apparent cache-problem; and because developers need to know where to look for artifacts such as log-files etc. for diagnostic/debugging purposes of applications in production, and
    • source-control - you may or may not wish to store run-time and permanent assets under the application project folder itself, but it's common enough, and often is the default, even if most projects make this configurable; developers need to know which folders to exclude from source-control and/or IDE analysis etc.

    I haven't looked at existing applications or frameworks to see how these folders are named, but I believe it's a fact that most (if not all) web-applications (at least) have designated folders for permanent and run-time data, as most applications do have both some kind of cache-folder and a folder for user-generated files.

    I'm guessing it would take more than a statistical survey to propose specific folder-names for (2) and (3) but at this stage merely wanted to explain why I think these two folder-designations are important - even if there is no statistical common average for the naming of these folders, in my experience, most projects have them, and I think it would be useful to define these.

    I'm hoping the purpose of this specification is to establish more than a formalization of an existing de-facto standard for project structure, and so I feel that this may be an extremely important missing piece of the puzzle.

    Let me know what you think?

    opened by mindplay-dk 6
  • Check root folder permissions. Skip existing directories and files.

    Check root folder permissions. Skip existing directories and files.

    Fixes a number of bugs from #43:

    • Check whether the specified folder exists and that it has sufficient permissions.
    • Output a message specific to each of the errors above.
    • Existing folders and files do not cause a warning.
    • Existing files do not get overridden.
    • Add tests to prove the bugs in #43.
    opened by afilina 0
  • Update README with content examples

    Update README with content examples

    Added a few examples, since people will keep asking. We still have This publication does not otherwise define the structure and contents of the directory, so the spec remains reasonably neutral in that regard.

    Fixes #36

    opened by afilina 0
  • Question: Clarify

    Question: Clarify "resources" vs "vendor" in composer projects.

    First of I want to say thanks for this work!

    I'm still relatively a beginner developer. From reading this standard it appears to me that a "resources" directory is analogous to a "vendor" directory in a composer project. (I could be completely wrong)

    Considering the relative popularity of composer in PHP projects, how does this standard reconcile the two? Should the "vendor" directory substitute the "resources" directory in a composer project?

    Can the two folders be seen as conceptually being the same?

    opened by yeboahnanaosei 2
  • /src for main?

    /src for main?

    I put all my autoloaded classes into /src. But where do I put the source for my main* for a command-line executable? Does that go in /src? Someplace else?

    *main (like int main() in C/C++) -- the non-class entry point for the program, which typically receives the command line parameters via $argv.

    opened by cxj 1
  • /bin particulars

    /bin particulars

    Are the command-line executables which belong in /bin those which are delivered as part of the package? Or are they executables which are generated by the package, after delivery and installation, via some user-invoked means? Or both?

    opened by cxj 3
Releases(1.0.0)
Owner
null
A skeleton repository for Spatie's PHP Packages

:package_description This package can be used as to scaffold a framework agnostic package. Follow these steps to get started: Press the "Use template"

Spatie 335 Dec 25, 2022
Easy to use, fast extendable small PHP Framework, like the one you ever missed. The skeleton-APP

About Tufu-Framework Easy to use, fast extendable PHP Framework, like the one you ever missed. Features included such as: Twig and extensions. Fast ro

Giacomo Barbalinardo 0 Jul 2, 2022
Mako skeleton application.

Mako Framework Mako is a lightweight and easy to use PHP framework based on the MVC architectural design pattern. Check out the documentation and crea

Mako Framework 27 Nov 12, 2022
🎁 Datagrid component project skeleton based on Nette Framework

?? Datagrid component project skeleton based on Nette Framework

Contributte 4 Dec 14, 2022
Slim 3 skeleton working with Google App Engine include cron configuration.

Slim3 GAE Skeleton Slim 3 skeleton working with Google App Engine include cron configuration. Demo https://slim3-gae-skeleton.appspot.com/health_check

Jared Chu 2 May 10, 2018
A skeleton to get started with Silex

Silex Skeleton WARNING: Silex is in maintenance mode only. Ends of life is set to June 2018. Read more on Symfony's blog. Welcome to the Silex Skeleto

Silex 789 Dec 5, 2022
lumen ^6.0 skeleton

Lumen skeleton It can format code and check the error code when submit code. Use the best api response package of QeeZer/api-responder. Comprehensive

齐子 1 Apr 1, 2022
Slim Framework skeleton application with MVC Schema

Slim Framework skeleton application with MVC Schema

JingwenTian 9 Apr 29, 2021
The Yaf testable skeleton and composer supported.

The Yaf testable skeleton and composer supported

安正超 142 Nov 28, 2022
Slim Framework 3 Skeleton Application + PagSeguro Lib

Slim Framework 3 Skeleton Application + PagSeguro Lib Aplicação simples para geração do Token para pagamentos no PagSeguro (método transparente) e env

Raí Siqueira 1 Feb 26, 2018
Slim 3 MVC Skeleton With Swoole

Slim 3 MVC Skeleton With Swoole ##Features Quickly setup and start working on a new Slim Framework 3 . Use the latest Slim 3 with the PHP-View templat

kcloze 53 Aug 17, 2022
MaxPHP HTTP project skeleton.

轻量 • 简单 • 快速 一款基于swoole的组件化的轻量PHP框架,可以用作API开发,方便快速。 主要特性 组件和框架核心分离 基于 Psr7 的 HTTP-Message 基于 Psr11 的容器 基于 Psr14 的事件 基于 Psr15 的中间件 基于 Psr16 的缓存组件,支持 Fi

chengyao 9 Dec 15, 2022
📦 This is a repository of centralized management of all swoft core components

Swoft Component This repository is used to manage all swoft core components. 中文说明 中文说明请查看 README.zh-CN.md IMPORTANT All components will NOT be modifie

Swoft Cloud 95 Nov 16, 2022
a framework for WebDevelop based on the mvc structure. The name of this project for Fun because everyone can use it. Completely simple and powerful structure for all your projects

A_A (-.-) ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ |-| █▄─▄▄─█▄─██─▄█─▄▄▄▄█─▄▄▄▄█▄─█─▄█─▄▄▄─██▀▄─██─▄

MasihGhaznavi 7 Jun 29, 2022
REST APIs using Slim framework. Implemented all CRUD operations on the MySql database

PHP REST API using slim framework and CRUD operations ?? Hi there, this is a simple REST API built using the Slim framework. And this is for the folks

Hanoak 2 Jun 1, 2022
PSR Log - This repository holds all interfaces/classes/traits related to PSR-3.

PSR Log This repository holds all interfaces/classes/traits related to PSR-3. Note that this is not a logger of its own. It is merely an interface tha

PHP-FIG 10.1k Jan 3, 2023
PHP Kafka client is used in PHP-FPM and Swoole. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever.

longlang/phpkafka Introduction English | 简体中文 PHP Kafka client is used in PHP-FPM and Swoole. The communication protocol is based on the JSON file in

Swoole Project 235 Dec 31, 2022
FuelPHP v1.x is a simple, flexible, community driven PHP 5.3+ framework, based on the best ideas of other frameworks, with a fresh start! FuelPHP is fully PHP 7 compatible.

FuelPHP Version: 1.8.2 Website Release Documentation Release API browser Development branch Documentation Development branch API browser Support Forum

Fuel 1.5k Dec 28, 2022
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. PHP>=5.3.

Workerman What is it Workerman is an asynchronous event-driven PHP framework with high performance to build fast and scalable network applications. Wo

walkor 10.2k Dec 31, 2022