Building EventPress Part 1
Hey there! Just a note before you begin... I haven't written in a long while. I've been threatening to do so for ages, and I finally figured this was as good a topic to start with as any. I'm a little rusty but will try keep at it and hopefully improve.
EventPress is probably the biggest thing I work on. I've been involved since the very beginning and the app has grown exponentially through 3 major versions over the last 10 years. Version 4 is now on the table and there's a few changes I'd like to change as we work through it.
First, a little history. EventPress is owned by HotPress Media and was started because a client requested a simple solution to managing event RSVPs that could replace their Excel spreadsheet. That first version of EventPress was ugly. There was no spec, we ran the project without a proper plan and ended up with a giant bowl of spaghetti. But it worked, and it helped to get a foot in the door with one of the biggest companies in South Africa.
Version 2 was a big leap. We didn't change much in the way of Interface, but the underlying framework went through a big change. EventPress was moved to Laravel (version 5 at the time), and although a lot of the code from version 1 came across to version 2 the structure was much better and we had far less problems. We still didn't have any sort of test suite in those days and we basically tested stuff on the "it works on my machine" basis. Not great.
Version 3 brought a complete overhaul to the UI, and Tailwind became the preferred CSS framework. Lots of code was changed, even though there was still a fair amount of version 1 code hiding in dark corners. A big change to version 3 was a brand new distribution system. We learnt a lot about sending mass mail during that transition.
A lot of the public facing UI was a direct copy from version 2. Even now, much of what attendees see is still version 2 code. Instead, version 3 brought a lot more structure to the code base. There was a certain logic that started to come forward. We wrote thin controllers and leaned heavily on the service container. Version 3 was also the first version of EventPress to sport a test suite.
I've been writing PHP code for a long time, but I'm self-taught. EventPress was like being thrown in the deep end without any direction on how to swim. It was a massive learning curve, but it got me to where I am today. I built this thing myself with very little input from other developers.
This time around, I'm going to blog my way through the EventPress 4 development. Not because I'm looking for approval, but because I want to record it this time. And maybe my solutions could help other solo developers. I've learnt a lot about building and running large PHP applications.
EventPress 4 is going to be a large rewrite. Although plenty of EventPress 3 code will end up in version 4, it won't just be a copy-and-paste. I feel it's time to finally get rid of all the stale bits that have stuck around since version 1; I want a more robust test suite; and I want to take advantage of some newer tech.
My plan is to write something at least once a month as I work through this. I'll try force myself to keep it up.
So head first, into the fray...
Where to begin.
EventPress 4 will not be getting a new UI. We'll be using almost all of the interface from version 3, and maybe just a few minor changes here and there. EventPress' UI is built using Vue 3 and Tailwind and Inertia is our glue of choice.
EventPress 4 will be a 1-to-1 feature copy of version 3. This means that as version 3 evolves over the next few months, so version 4 needs to be grow alongside it. For now, though, it's just a bit of planning.
to begin with, I looked at where Version 3 was still struggling and made some notes on how those elements could be improved in version 4. I've built up an idea of how I'd like to approach building this version of EventPress. There's some familiarity and some brand new things:
- Laravel 11
- Vue 3
- InertiaJS 2
- Laravel Octane on FrankenPHP
- PHP 8.4
- MySQL (And SQLSRV for out Enterprise Clients)
- Caddy
There's some interesting choices in there, I know. The Octane one is a big one for us since we've never used something like that before. Octane is a first party package for Laravel that helps run your app on a PHP application server. Swoole, RoadRunner and FrankenPHP are supported. We looked at all three options and decided on FrankenPHP for now. It's newer than the other two, but offers really goo performance. Swoole offers has concurrent workers, which is nice, but not something we see ourselves needing. The deal breaker, however, was that it requires the Swoole extension be installed. That's not something we can expect our enterprise clients to do. I also have some experience with FrankenPHP, so that made sense.
We've used Nginx for years. It's great and I cannot recommend it enough. However, FrankenPHP comes with it's own Caddy server, so we're experimenting with this as well. We might not stick to Caddy, but for now, it's on the list.
PHP 8.4 hasn't been released just yet, but since EventPress 4 won't be out for a while, it made sense to start on the latest version we can. As of writing, PHP 8.4 is about a month away from release, so we're using the latest release candidate.
InertiaJS 2 is much the same story. It's also in BETA, but since we're a long way from release, it will probably be out long before EventPress is. Besides, we ran InertiaJS 1 in BETA for ages without issues.
Static Analysis
I'm a recent static analysis convert. The most I've used is the stuff that PHPStorm gives me as a I coded. For EventPress 4, we've decided to go full hog and bring PHPStan into the mix. PHPStan is a third-party static analyser for PHP. It's dead simple to configure and has helped me to weed out a few bugs in a number of other projects.
Based on the size of EventPress it makes sense here as well. To make this work, I've added a test:types Composer script which I can run whenever I want and an be added to the CI script.
Code Linting
I've never run a PHP code linter. I've used PHP Mess Detector a few times, but never really got stuck into it. For EventPress 4, we've decided that a linter will help to keep code neat and consistent. We've opted for Laravel's own "Pint" which is really just a wrapper around PHP-CS-Fixer and provides a really simple way to keep our code tidy. Again, I've added lint and test:lint Composer scripts to make it easier to run.
Dev Environment
I work on both Mac and Linux machines during development. I have an M1 Max on my desk that I've had for a few years, and a few Linux machines dotted around the office. My main driver is the Mac and I do most of my development work there, but all my code runs on Linux machines. Usually Ubuntu Server.
EventPress 4 adds a few new pieces to the puzzle, but I think for the most part I can continue to develop the way I currently do. I use Homebrew to install most of the tools and Laravel Valet to run local dev environments. I'm not a Laravel Herd user (It's good, but I fell like more of a Herd Pro user and I can't justify spending $99 a year for a tool that does everything I can do already, just a little quicker and wrapped in a nice UI).
So my plan is have an eventpress4.test domain running with a MySQL database on my local machine. I'll use this state for a while during early development and just do some testing with Octane every few days or so. Once we're through the early part, we'll start development using Octane more regularly. We'll host a test server running the app as we intend it to run in production.
Containers
EventPress has never been containerised. However, EventPress 4 will likely go that way. We're still experimenting with a few things but we've been in conversation with some of our enterprise clients, and we feel that this will help to make the deployment process a lot easier for them. We have some early tests running EventPress 3 in a Docker container, and we feel like this is going to be the right move for all releases of EventPress going forward.
GIT
For years, we have relied heavily on GitLab as our CI/CD service of choice. GitLab runs a number of complex CI pipelines and does deployment for almost every project I work on.
However, I've also been a GitHub user for many years. I've used it mainly for my open-source work, but recently started moving some smaller projects to a paid-for GitHub account and I've been super impressed. There's a few things that work very differently to GitLab, but in most aspects I'm really happy.
So EventPress 4 code will be hosted at GitHub and we'll use Actions for or CI pipeline and all deployments.
Ready, set go!
I think that's it for this post. There's still some planning to go through, but I have started putting some code down and writing some tests. I've already got a basic authentication layer going (Thanks Laravel), although most of that it similar to EventPress 3. I'll show some code in the next one. Promise!
The above is the detailed content of Building EventPress Part 1. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

RESTAPI design principles include resource definition, URI design, HTTP method usage, status code usage, version control, and HATEOAS. 1. Resources should be represented by nouns and maintained at a hierarchy. 2. HTTP methods should conform to their semantics, such as GET is used to obtain resources. 3. The status code should be used correctly, such as 404 means that the resource does not exist. 4. Version control can be implemented through URI or header. 5. HATEOAS boots client operations through links in response.

In PHP, exception handling is achieved through the try, catch, finally, and throw keywords. 1) The try block surrounds the code that may throw exceptions; 2) The catch block handles exceptions; 3) Finally block ensures that the code is always executed; 4) throw is used to manually throw exceptions. These mechanisms help improve the robustness and maintainability of your code.

The main function of anonymous classes in PHP is to create one-time objects. 1. Anonymous classes allow classes without names to be directly defined in the code, which is suitable for temporary requirements. 2. They can inherit classes or implement interfaces to increase flexibility. 3. Pay attention to performance and code readability when using it, and avoid repeatedly defining the same anonymous classes.
