├── .env ├── src ├── styles │ ├── tailwind.css │ └── global.css ├── scripts │ ├── nav.ts │ ├── globals.d.ts │ └── repos.ts └── partials │ ├── common │ └── Nav.php │ └── layouts │ └── Common.php ├── configs ├── env.php └── routes.php ├── .prettierignore ├── bin └── composer.phar ├── .vscode └── settings.json ├── system └── main.php ├── .editorconfig ├── .gitignore ├── raw └── .htaccess ├── pages ├── index.php ├── ipsum.php └── about.php ├── index.php ├── .prettierrc ├── tsconfig.json ├── .github └── FUNDING.yml ├── composer.json ├── LICENSE ├── package.json ├── vite.config.ts ├── composer.lock ├── README.md └── public └── logo.svg /.env: -------------------------------------------------------------------------------- 1 | VITE_NAME_ENV=Vite 2 | -------------------------------------------------------------------------------- /src/styles/tailwind.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss'; 2 | -------------------------------------------------------------------------------- /configs/env.php: -------------------------------------------------------------------------------- 1 | ('#nav')!; 2 | 3 | nav.innerHTML += `Ipsum`; 4 | 5 | export {}; 6 | -------------------------------------------------------------------------------- /src/styles/global.css: -------------------------------------------------------------------------------- 1 | @reference "tailwindcss"; 2 | 3 | a[href^='http'] { 4 | @apply underline; 5 | @apply text-sky-800; 6 | 7 | @apply hover:no-underline; 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "editor.defaultFormatter": "esbenp.prettier-vscode", 4 | "typescript.tsdk": "node_modules/typescript/lib" 5 | } 6 | -------------------------------------------------------------------------------- /system/main.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | declare const BASE: string; 4 | 5 | interface ImportMetaEnv { 6 | readonly BASE: string; 7 | } 8 | 9 | interface ImportMeta { 10 | readonly env: ImportMetaEnv; 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build output 2 | dist 3 | 4 | # generated files 5 | .php-tmp 6 | 7 | # dependencies 8 | node_modules 9 | vendor 10 | 11 | # logs 12 | npm-debug.log* 13 | yarn-debug.log* 14 | yarn-error.log* 15 | pnpm-debug.log* 16 | 17 | # environment variables 18 | *.local 19 | 20 | # macOS-specific files 21 | .DS_Store 22 | -------------------------------------------------------------------------------- /src/partials/common/Nav.php: -------------------------------------------------------------------------------- 1 | 8 | 12 | 13 | 14 | ('#repos')!; 2 | 3 | links.innerHTML += `vite-plugin-php`; 4 | links.innerHTML += `PHP-Components`; 5 | links.innerHTML += `vite-plugin-php-components`; 6 | 7 | export {}; 8 | -------------------------------------------------------------------------------- /pages/index.php: -------------------------------------------------------------------------------- 1 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
+
10 | 11 | 12 |
13 | 14 |
15 |
16 | 17 | 18 |
19 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | getMessage()); 20 | } 21 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/prettierrc", 3 | "phpVersion": "7.3", 4 | "plugins": ["@prettier/plugin-php"], 5 | "printWidth": 80, 6 | "tabWidth": 4, 7 | "useTabs": true, 8 | "semi": true, 9 | "singleQuote": true, 10 | "jsxSingleQuote": false, 11 | "quoteProps": "consistent", 12 | "trailingComma": "all", 13 | "trailingCommaPHP": true, 14 | "braceStyle": "1tbs", 15 | "bracketSpacing": true, 16 | "jsxBracketSameLine": false, 17 | "arrowParens": "always", 18 | "htmlWhitespaceSensitivity": "ignore", 19 | "endOfLine": "lf", 20 | "embeddedLanguageFormatting": "auto" 21 | } 22 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "types": ["vite/client", "node"], 5 | "target": "ESNext", 6 | "useDefineForClassFields": true, 7 | "module": "ESNext", 8 | "lib": ["ESNext", "DOM"], 9 | "moduleResolution": "Node", 10 | "strict": true, 11 | "sourceMap": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "esModuleInterop": true, 15 | "noEmit": true, 16 | "noUnusedLocals": true, 17 | "noUnusedParameters": true, 18 | "noImplicitReturns": true, 19 | "skipLibCheck": true, 20 | "paths": { 21 | "~/*": ["./src/*"] 22 | } 23 | }, 24 | "include": ["src"] 25 | } 26 | -------------------------------------------------------------------------------- /pages/ipsum.php: -------------------------------------------------------------------------------- 1 | 3 |
4 | 5 | 6 |
7 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [donnikitos] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: donnikitos 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: donnikitos 14 | custom: ['https://www.paypal.com/donate/?hosted_button_id=EPXZPRTR7JHDW'] 15 | -------------------------------------------------------------------------------- /src/partials/layouts/Common.php: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | <?= $this->title; ?> 17 | 18 | 19 | 20 | 21 | 22 | 23 | children; ?> 24 | 25 | 26 | 27 | =7.3", 29 | "nikic/fast-route": "^1.3", 30 | "nititech/html-components": "^1.0" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /pages/about.php: -------------------------------------------------------------------------------- 1 | 3 |
4 | 5 | 6 |
7 | This is a PHP-Vite starter repo for modern web development with PHP.
8 | This repository also demonstrates the usage of so called "PHP-components".
9 |
10 | It contains all the basic needs to start developing modern PHP applications: 11 |
    12 |
  • TypeScript/ JavaScript transpilation
  • 13 |
  • Tailwind CSS implementation
  • 14 |
  • Out of the box SASS/ SCSS support
  • 15 |
  • EJS template language support
  • 16 |
  • Image transform tools
  • 17 |
  • SVG loader
  • 18 |
  • 19 | Enabled componentization using PHP-Components and 20 | vite-plugin-php-components 21 |
  • 22 |
23 |
24 |
25 |
26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 nititech.de - Nikita Nitichevski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /configs/routes.php: -------------------------------------------------------------------------------- 1 | addRoute('GET', '/', function ($ROUTE_PARAMS) { 5 | include('pages/index.php'); 6 | }); 7 | 8 | $r->addRoute('GET', '/about', function ($ROUTE_PARAMS) { 9 | include('pages/about.php'); 10 | }); 11 | 12 | $r->addRoute('GET', '/ipsum', function ($ROUTE_PARAMS) { 13 | include('pages/ipsum.php'); 14 | }); 15 | }); 16 | 17 | // Fetch method and URI from somewhere 18 | $httpMethod = $_SERVER['REQUEST_METHOD']; 19 | $uri = $_SERVER['REQUEST_URI']; 20 | 21 | // Strip query string (?foo=bar) and decode URI 22 | if (false !== $pos = strpos($uri, '?')) { 23 | $uri = substr($uri, 0, $pos); 24 | } 25 | $uri = rawurldecode($uri); 26 | 27 | $routeInfo = $dispatcher->dispatch($httpMethod, $uri); 28 | switch ($routeInfo[0]) { 29 | case FastRoute\Dispatcher::NOT_FOUND: 30 | http_response_code(404); 31 | die('Not found...'); 32 | break; 33 | // case FastRoute\Dispatcher::METHOD_NOT_ALLOWED: 34 | // $allowedMethods = $routeInfo[1]; 35 | // // ... 405 Method Not Allowed 36 | // break; 37 | case FastRoute\Dispatcher::FOUND: 38 | $routeInfo[1]($routeInfo[2]); 39 | break; 40 | } 41 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "modern-php-vite-starter", 3 | "description": "An even modern vanilla PHP-Vite starter repo, utilizing vite-plugin-php and with enabled PHP-Components", 4 | "version": "1.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc --noEmit && vite build", 9 | "composer": "php ./bin/composer.phar" 10 | }, 11 | "keywords": [ 12 | "modern-php-vite-starter", 13 | "modern php starter", 14 | "modern php", 15 | "php starter", 16 | "php-vite-starter", 17 | "vite", 18 | "php", 19 | "php components", 20 | "starter", 21 | "template", 22 | "tailwindcss", 23 | "tailwind", 24 | "typescript", 25 | "auto-refresh", 26 | "auto-reload", 27 | "sass", 28 | "scss", 29 | "starter-repo", 30 | "php-starter" 31 | ], 32 | "readme": "README.md", 33 | "license": "See MIT license in LICENSE", 34 | "homepage": "https://github.com/nititech/php-vite-starter", 35 | "repository": { 36 | "type": "git", 37 | "url": "https://github.com/nititech/php-vite-starter.git" 38 | }, 39 | "bugs": { 40 | "url": "https://github.com/nititech/php-vite-starter/issues", 41 | "email": "mail@nititech.de" 42 | }, 43 | "author": { 44 | "name": "nititech", 45 | "email": "mail@nititech.de", 46 | "url": "https://nititech.de" 47 | }, 48 | "devDependencies": { 49 | "@prettier/plugin-php": "^0.24.0", 50 | "@tailwindcss/vite": "^4.1.16", 51 | "@types/node": "^24.9.2", 52 | "prettier": "^3.6.2", 53 | "sass": "^1.93.2", 54 | "tailwindcss": "^4.1.16", 55 | "typescript": "^5.9.3", 56 | "vite": "^7.1.12", 57 | "vite-imagetools": "^9.0.0", 58 | "vite-plugin-ejs": "^1.7.0", 59 | "vite-plugin-php": "^3.0.0-beta.4", 60 | "vite-plugin-php-components": "^0.0.91", 61 | "vite-plugin-static-copy": "^3.1.4", 62 | "vite-plugin-svgr": "^4.5.0", 63 | "vite-tsconfig-paths": "^5.1.4" 64 | }, 65 | "trustedDependencies": [ 66 | "@parcel/watcher" 67 | ] 68 | } 69 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | // vite.config.js 2 | import { defineConfig } from 'vite'; 3 | import { fileURLToPath } from 'node:url'; 4 | import usePHP from 'vite-plugin-php'; 5 | import { viteStaticCopy } from 'vite-plugin-static-copy'; 6 | import { ViteEjsPlugin } from 'vite-plugin-ejs'; 7 | import { imagetools } from 'vite-imagetools'; 8 | import { existsSync } from 'node:fs'; 9 | import tailwindcss from '@tailwindcss/vite'; 10 | import transpilePHPComponents from 'vite-plugin-php-components'; 11 | 12 | export default defineConfig(({ command }) => { 13 | const publicBasePath = '/modern-php-vite-starter/'; // Change if deploying under a nested public path. Needs to end with a /. See https://vitejs.dev/guide/build.html#public-base-path 14 | 15 | const base = command === 'serve' ? '/' : publicBasePath; 16 | const BASE = base.substring(0, base.length - 1); 17 | 18 | return { 19 | base, 20 | plugins: [ 21 | imagetools(), 22 | transpilePHPComponents(), 23 | usePHP({ 24 | entry: [ 25 | 'index.php', 26 | 'configs/env.php', 27 | 'pages/**/*.php', 28 | 'src/partials/**/*.php', 29 | ], 30 | rewriteUrl(requestUrl) { 31 | const filePath = fileURLToPath( 32 | new URL('.' + requestUrl.pathname, import.meta.url), 33 | ); 34 | const publicFilePath = fileURLToPath( 35 | new URL( 36 | './public' + requestUrl.pathname, 37 | import.meta.url, 38 | ), 39 | ); 40 | 41 | if ( 42 | !requestUrl.pathname.includes('.php') && 43 | (existsSync(filePath) || existsSync(publicFilePath)) 44 | ) { 45 | return undefined; 46 | } 47 | 48 | requestUrl.pathname = 'index.php'; 49 | 50 | return requestUrl; 51 | }, 52 | }), 53 | ViteEjsPlugin({ 54 | BASE, 55 | }), 56 | viteStaticCopy({ 57 | targets: [ 58 | { src: 'public', dest: '' }, 59 | { src: 'system', dest: '' }, 60 | { src: 'configs', dest: '', overwrite: false }, 61 | { src: 'vendor', dest: '' }, 62 | ], 63 | silent: command === 'serve', 64 | }), 65 | tailwindcss(), 66 | ], 67 | define: { 68 | 'BASE': JSON.stringify(BASE), 69 | 'import.meta.env.BASE': JSON.stringify(BASE), 70 | }, 71 | resolve: { 72 | alias: { 73 | '~/': fileURLToPath(new URL('./src/', import.meta.url)), 74 | }, 75 | }, 76 | publicDir: command === 'build' ? 'raw' : 'public', 77 | css: { 78 | preprocessorOptions: { 79 | scss: { 80 | api: 'modern-compiler', 81 | }, 82 | }, 83 | }, 84 | server: { 85 | port: 3000, 86 | }, 87 | build: { 88 | assetsDir: 'public', 89 | emptyOutDir: true, 90 | }, 91 | }; 92 | }); 93 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "20b0086b6beab3cf516264f55f2667f1", 8 | "packages": [ 9 | { 10 | "name": "nikic/fast-route", 11 | "version": "v1.3.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/nikic/FastRoute.git", 15 | "reference": "181d480e08d9476e61381e04a71b34dc0432e812" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/nikic/FastRoute/zipball/181d480e08d9476e61381e04a71b34dc0432e812", 20 | "reference": "181d480e08d9476e61381e04a71b34dc0432e812", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "php": ">=5.4.0" 25 | }, 26 | "require-dev": { 27 | "phpunit/phpunit": "^4.8.35|~5.7" 28 | }, 29 | "type": "library", 30 | "autoload": { 31 | "files": [ 32 | "src/functions.php" 33 | ], 34 | "psr-4": { 35 | "FastRoute\\": "src/" 36 | } 37 | }, 38 | "notification-url": "https://packagist.org/downloads/", 39 | "license": [ 40 | "BSD-3-Clause" 41 | ], 42 | "authors": [ 43 | { 44 | "name": "Nikita Popov", 45 | "email": "nikic@php.net" 46 | } 47 | ], 48 | "description": "Fast request router for PHP", 49 | "keywords": [ 50 | "router", 51 | "routing" 52 | ], 53 | "support": { 54 | "issues": "https://github.com/nikic/FastRoute/issues", 55 | "source": "https://github.com/nikic/FastRoute/tree/master" 56 | }, 57 | "time": "2018-02-13T20:26:39+00:00" 58 | }, 59 | { 60 | "name": "nititech/html-components", 61 | "version": "v1.0.0", 62 | "source": { 63 | "type": "git", 64 | "url": "https://github.com/donnikitos/php-html-components.git", 65 | "reference": "d2b5eb4f37770e9418ed2bb85cc766775c68df63" 66 | }, 67 | "dist": { 68 | "type": "zip", 69 | "url": "https://api.github.com/repos/donnikitos/php-html-components/zipball/d2b5eb4f37770e9418ed2bb85cc766775c68df63", 70 | "reference": "d2b5eb4f37770e9418ed2bb85cc766775c68df63", 71 | "shasum": "" 72 | }, 73 | "require": { 74 | "php": ">=7.0" 75 | }, 76 | "type": "library", 77 | "autoload": { 78 | "psr-4": { 79 | "": "src/" 80 | } 81 | }, 82 | "notification-url": "https://packagist.org/downloads/", 83 | "license": [ 84 | "MIT" 85 | ], 86 | "authors": [ 87 | { 88 | "name": "Nikita 'donnikitos' Nitichevski", 89 | "homepage": "https://donnikitos.com", 90 | "role": "Developer" 91 | } 92 | ], 93 | "description": "Create intuitive, reusable HTML components", 94 | "homepage": "https://github.com/donnikitos/php-html-components", 95 | "keywords": [ 96 | "PHP-components", 97 | "class components", 98 | "component", 99 | "components", 100 | "html" 101 | ], 102 | "support": { 103 | "issues": "https://github.com/donnikitos/php-html-components/issues", 104 | "source": "https://github.com/donnikitos/php-html-components/tree/v1.0.0" 105 | }, 106 | "time": "2025-05-11T12:44:01+00:00" 107 | } 108 | ], 109 | "packages-dev": [], 110 | "aliases": [], 111 | "minimum-stability": "stable", 112 | "stability-flags": {}, 113 | "prefer-stable": false, 114 | "prefer-lowest": false, 115 | "platform": { 116 | "php": ">=7.3" 117 | }, 118 | "platform-dev": {}, 119 | "plugin-api-version": "2.6.0" 120 | } 121 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

PHP-Vite Starter Repo by nititech

2 | 3 | modern-php-vite-starter is a modern vanilla PHP-Vite starter repository designed to provide developers with the essential tools to kickstart their development of modern componentized PHP applications.\ 4 | This repository utilizes [Vite](https://vitejs.dev/), [`vite-plugin-php` plugin](https://github.com/donnikitos/vite-plugin-php) and [PHP-Components](https://github.com/donnikitos/php-html-components) + [`vite-plugin-php-components` plugin](https://github.com/nititech/vite-plugin-php-components) to improve developer experience and provide various features to streamline development. 5 | 6 | ## Features 7 | 8 | - **Auto-refresh / auto-reloading** 9 | - **PHP-Components**: Use components in your PHP code to reuse existing code and improve DX. 10 | - **JS environmental variables in PHP**: Use environmental variables supplied in `.env` or to Vite in your PHP code. 11 | - **FastRoute router**: Fast and simple preconfigured router. 12 | - **TypeScript / JavaScript Transpilation**: Write modern JavaScript or TypeScript code, which will be automatically transpiled to browser-compatible JavaScript. 13 | - **Tailwind CSS Implementation**: Utilize Tailwind CSS for rapid UI development with utility-first classes. 14 | - **SASS / SCSS Support**: Write styles using SASS or SCSS syntax, with built-in support for compilation. 15 | - **EJS Template Language Support**: Use the EJS (Embedded JavaScript) templating language for using JavaScript pieces in your PHP-files. 16 | - **Image Transform Tools**: Easily manage and transform images as needed for your application. 17 | - **SVG Loader**: Load SVG files directly into your project, allowing for scalable vector graphics usage. 18 | 19 | ## Usage 20 | 21 | 1. **Clone the Repository**: Start by cloning this repository to your local machine. 22 | 23 | ```bash 24 | git clone https://github.com/nititech/modern-php-vite-starter.git 25 | ``` 26 | 27 | 2. **Install Dependencies**: Navigate into the project directory and install the necessary dependencies using npm or yarn. 28 | 29 | ```bash 30 | cd modern-php-vite-starter 31 | npm install 32 | npm run composer install 33 | ``` 34 | 35 | ## Development 36 | 37 | 3. Start the development server, just run the following command: 38 | 39 | ```bash 40 | npm run dev 41 | ``` 42 | 43 | Now you can access your application. Once the server is running, you can access your application by navigating to http://localhost:3000/ in your web browser. 44 | 45 | ## Project Structure 46 | 47 | ##### /bin 48 | 49 | ``` 50 | ├── bin 51 | │ ├── composer.phar 52 | │ ├── **/* 53 | ``` 54 | 55 | - This folder is supposed to hold binaries that are needed for project compilations and such 56 | - Currently holds only `composer.phar` for the `composer` command 57 | 58 | ##### /index.php 59 | 60 | This is the app entry point ⚠️ 61 | 62 | - Routing is now programmatic and uses [nikic' `FastRoute`](https://github.com/nikic/FastRoute) router -> for configuration see the `/configs/routes.php` file 63 | - Non-PHP files will not go through this router 64 | - Nonexisting files and paths will go through this router 65 | 66 | ##### /configs 67 | 68 | ``` 69 | ├── configs 70 | │ ├── env.php 71 | │ ├── routes.php 72 | │ ├── **/* 73 | ``` 74 | 75 | - `env.php` will be transpiled using Vite and the `vite-plugin-php` plugin -> here you can store tokens or other constants that should be reused through the app.\ 76 | We use it to define the constants that we import from Vite. 77 | - `routes.php` holds the routing configuration that is being used by FastRoute 78 | 79 | ##### /pages 80 | 81 | ``` 82 | ├── pages 83 | │ ├── **/*.php 84 | ``` 85 | 86 | - This `.php` files will be transpiled using Vite and the `vite-plugin-php` plugin 87 | 88 | ##### /src 89 | 90 | ``` 91 | ├── src 92 | │ ├── scripts 93 | │ │ ├── **/* 94 | │ ├── styles 95 | │ │ ├── **/* 96 | ``` 97 | 98 | - This folder should be used for files that need be handled by Vite 99 | - Files can be accessed for example by `/src/styles/example-style.scss` or `/src/scripts/some-script.ts` 100 | 101 | ##### /src/partials 102 | 103 | ``` 104 | ├── src 105 | │ ├── partials 106 | │ │ ├── **/*.php 107 | ``` 108 | 109 | - Folder for the PHP-Components 110 | - The components should be placed into sub folders and under the same namespace - a `spl_autoload_register()` handles the automatic inclusion of these files, see `/system/main.php`. 111 | - These `.php` files will be transpiled using Vite and the `vite-plugin-php` plugin 112 | 113 | ##### /public 114 | 115 | ``` 116 | ├── public 117 | │ ├── **/* 118 | ``` 119 | 120 | - Publicly accessible files should be placed here 121 | - Can be accessed by `/example-file.extension` in image, script, style, ... tags 122 | - Files will not be transpiled 123 | 124 | ##### /raw 125 | 126 | ``` 127 | ├── raw 128 | │ ├── .htaccess 129 | │ ├── **/* 130 | ``` 131 | 132 | - These files will be copied into the root of your build 133 | - Usually used for configurations, routers and so on (like the included `.htaccess`) 134 | 135 | ##### /system 136 | 137 | ``` 138 | ├── system 139 | │ ├── main.php 140 | │ ├── **/* 141 | ``` 142 | 143 | - `.php` files in this folder will not be transpiled 144 | - Usually used for autoloaders, database connections etc. 145 | - Contains `main.php` with the autoloader for PHP-Components 146 | 147 | ##### /vendor 148 | 149 | ``` 150 | ├── vendor 151 | │ ├── **/* 152 | ``` 153 | 154 | - Vendor files installed by Composer 155 | - `.php` Files will not be transpiled 156 | 157 | ## Production Build 158 | 159 | To generate a production build of your project, use: 160 | 161 | ```bash 162 | npm run build 163 | ``` 164 | 165 | #### Output 166 | 167 | All files will be generated and copied into the `/dist` folder. 168 | 169 | ``` 170 | ├── dist 171 | │ ├── configs (Files copied from the ./configs folder) 172 | │ │ ├── env.php (Transpiled to include environmental variables) 173 | │ │ ├── routes.php 174 | │ │ ├── **/* 175 | │ ├── pages 176 | │ │ ├── **/* (Transpiled PHP files from your ./pages folder) 177 | │ │ 178 | │ ├── src 179 | │ │ ├── partials 180 | │ │ │ ├── **/* (Transpiled PHP files from your ./partials folder) 181 | │ │ 182 | │ ├── public (Publicly accessible files, usually assets) 183 | │ │ ├── **/* (Files copied from the ./src/public folder) 184 | │ │ 185 | │ ├── system 186 | │ │ ├── **/* (Files copied from the ./system folder) 187 | │ │ 188 | │ ├── vendor 189 | │ │ ├── **/* (Files copied from the ./vendor folder, usually Composer packages) 190 | │ │ 191 | │ ├── .htaccess 192 | │ ├── **/* (Files copied from the ./raw folder) 193 | ``` 194 | 195 | ## Configuration 196 | 197 | This starter repository comes with default configurations for various tools. However, you can customize these configurations according to your project requirements. Key configuration files include: 198 | 199 | - **configs/routes.php**: Routing configuration. 200 | - **configs/env.php**: Globally accessible constants for PHP. 201 | - **tsconfig.json**: TypeScript configuration file. Modify this file to adjust TypeScript compiler options. 202 | - **.prettierrc**: Prettier configuration file for code formatting. Modify this file to customize code formatting rules. 203 | - **vite.config.ts**: Contains configuration settings for Vite, such as plugins, build options, and server settings. 204 | 205 | ## License 206 | 207 | This project is licensed under the MIT license, see LICENSE. 208 | 209 | ## Contributing 210 | 211 | Contributions are welcome! If you have any suggestions, improvements, or bug fixes, please feel free to open an issue or submit a pull request. 212 | 213 | 214 | 215 | 218 | 221 | 224 | 225 | 226 | 231 | 236 | 241 | 242 |
216 | via Ko-Fi 217 | 219 | Buy me a coffee 220 | 222 | via PayPal 223 |
227 | 228 | ko-fi 229 | 230 | 232 | 233 | Buy Me A Coffee 234 | 235 | 237 | 238 | PayPal 239 | 240 |
243 | 244 | ## Acknowledgments 245 | 246 | Special thanks to the developers of Vite, Tailwind CSS, FastRoutes, and other tools used in this starter repository for their fantastic work. 247 | -------------------------------------------------------------------------------- /public/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | Official PHP Logo 3 | 4 | 5 | 6 | image/svg+xml 7 | 8 | Official PHP Logo 9 | 10 | 11 | Colin Viebrock 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Copyright Colin Viebrock 1997 - All rights reserved. 24 | 25 | 26 | 1997 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | --------------------------------------------------------------------------------