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 |
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 |
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 |
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 |
96 |
--------------------------------------------------------------------------------