Jump to content

Craig

Members
  • Posts

    369
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Craig

  1. I use https://github.com/spatie/url-signer for something similar.
  2. It looks like it's just DO that has poor performance on their managed DBs. I presume you've seen this thread - https://www.digitalocean.com/community/questions/managed-db-become-very-very-slow ? As a final test, you could match the DB machine size to the current server and try again, but I have a feeling it might not help much and there's a wider problem. If separating out your DB is the goal, perhaps running it on a separate VM might be more than enough.
  3. I never use themes, UiKit, or Tailwind; so it's a no for me πŸ™‚ Every site I build is different, and so the CSS, modules and code for each site is also different.
  4. I use Sublime Text as my editor. I've tried others, but haven't found anything close to Sublime in terms of usability and performance. Most PW projects use the following modules: ProFields FormBuilder Wireframe ProcessCacheControl AdminTemplateColumns Any additional PHP dependencies are added via Composer. I use Laravel Mix to handle front-end compilation / bundling of SCSS and JS. It's a nice "wrapper" around Webpack that simplifies this process a lot. (View one of my webpack.mix.js files that runs PurgeCSS for production builds) All code in Git repositories hosted on GitHub, and use Sublime Merge as a Git GUI. Hosting-wise, most PW sites are on a Krystal reseller account or a client's hosting (if you use referral code 'CRAIG' we share Β£20 equally). For new sites, I do set up staging/development versions as a subdomain so it can be previewed. For deployment, I use DeployHQ (referral link / normal link) (also by Krystal) - which handles the transfer of changed files from Git over to the hosting via SSH - either manually or on Git push. It also does the front-end build step and Composer package installation as well so I don't have to do that myself. During development, I disable the template cache with this in a ready.php hook. // (I also set `$config->env = 'development';` elsewhere) if ($this->config->env === 'development') { $this->addHookBefore('Page::render', function($event) { $args = $event->arguments(1); $args['allowCache'] = false; $event->setArgument(1, $args); }); } I recently posted about how I do separate configs for different environments.
  5. This is what I do, which is almost like (2). site/config.php: <?php namespace ProcessWire; if(!defined("PROCESSWIRE")) die(); // Other PW default config values... // ... $config->dbHost = 'localhost'; $config->dbName = 'example_site'; $config->dbUser = ''; $config->dbPass = ''; $config->dbPort = '3306'; $config->dbCharset = 'utf8mb4'; $config->dbEngine = 'InnoDB'; // Environment overwrite if (file_exists(__DIR__ . '/config.local.php')) { require_once(__DIR__ . '/config.local.php'); } config.local.php: <?php namespace ProcessWire; $config->dbUser = 'example_site_user'; $config->dbPass = 'example_user_pass_123456'; config.local.php is in .gitignore, so never committed, and separate config.local.php files exist on testing / live environments. (I use DeployHQ and this is added as a config file that gets deployed with the rest of the code). To me, the benefits of this approach means that the entire config can be changed depending on the environment, and used to turn things on or off, like debug or advanced mode.
  6. I'd like to add another vote to the notion of using something like htmx or Unpoly - I like them, a lot. Having used them on various projects, both have pros and cons (like most things) and satisfy different use cases. I know PW is quick, and the template caching improves on things, but I recently launched a site that made use of Unpoly's up-preload and up-instant functionality - the perceived speed of page loads makes it feel like a static site. The client's response on seeing the dev preview was "I was not expecting a like for like copy! Especially one that is that fast." (their emphasis; it was a redevelopment of a bad WordPress build). With Unpoly, I find the modal, popup and drawer UI are great. Having those integrated with the dynamic functionality is a plus, and means I don't have to worry about whichever underlying CSS framework is being used or pulling in a separate dependency to provide that. It's not perfect; some interactions, particularly nested ones, need a bit more care to make sure the server responses and front-end attributes are all present and correct. I also make heavy use of the "compiler" functionality. This is essentially your "$(document).ready()" equivalent which lets you initialise your client-side components (like maps or colour pickers, for example) on both initial page load as well as any time they happen to be added to the page dynamically via AJAX as the result of an Unpoly request. htmx sits at a bit of a lower level, and provides events and a plugin system to extend it and hook into different interactions. When you need to do client-side things, you will still need some javascript to get the job done; or you could use htmx's sister project _hyperscript. Either way, I'd be happy to see any of these become part of the PW admin. πŸ™‚
  7. Hi Marcel! I think this is a small mistake in the module code. I'll release an update soon, but for now, you can change it manually as follows: In WayFathomAnalytics.module.php, at line 150, change it to this: private static function getEmbedConfig(array $data) (add the word 'static' after private).
  8. Hi Dan! I'm a part-time freelance PW developer (full-time employed elsewhere working on bespoke SaaS), based in the UK, and would be happy to take a look at the issues on the TKP site. Feel free to message me on the forum, or you can reach me on email: craig (@) onhover.co.uk.
  9. When processing a booking, you could include the current number of available spaces that the user was shown. Before finalising or saving the booking, you can check if the number sent through matches the current live value. If the live value is the same, and you have available spaces for the requested quantity, you are fine to decrease the amount. If the live value is lower, then someone else has grabbed them, so you can handle this situation as you please.
  10. I've got accounts with Fathom and Plausible, which are both great.
  11. Hi! I'd recommend doing it this way, using a single PHP DateTime object: <?php $date = new DateTime(); $days = []; while (count($days) < 7) { $days[] = $date->format('D'); $date->modify('-1 day'); } print_r($days); /* Array ( [0] => Tue [1] => Mon [2] => Sun [3] => Sat [4] => Fri [5] => Thu [6] => Wed ) */
  12. Fantastic site all-round and a great write-up here. Well done on the project, and thanks! πŸ™‚
  13. I had a .me domain for an still-in-progress side project, but the high renewal price prompted me to look elsewhere. I ended up getting a .xyz for a much better price πŸ™‚
  14. Unfortunately, PW only supports one dimension for arrays when using the API to process data. There's been some discussion on this topic at GitHub: https://github.com/processwire/processwire-issues/issues/387
  15. I've been using RunCloud for a couple of years now, both at work and for my own/clients use. I originally wanted to go with Ploi, but unfortunately the features I needed just weren't ready at the time, so have stuck with RunCloud. I'm also invested in using the RunCloud API to automate the setup of some projects, so there's that too. I have two wishes for RC, and that is that they introduce third party backup destinations (i.e. your own S3 buckets) and have fewer WordPress-only features.
  16. SSH and FTP won't be affected by .htaccess, as it's only the web server (Apache, usually) that processes the directives in that file. If it's failing, it could be due to the import tool trying to validate the web-accessible presence of the files it sees via SSH/FTP by making a typical web request (that is handled by Apache) - and it's those requests that PW could be blocking. Another reason could be if the directories it isn't finding is done by some sort of symlink, or there are some permission issues preventing it from working. Without any detailed logs or knowledge of the import tool, I can't suggest anything other than that! πŸ™‚
  17. Craig

    Wireframe

    Like RockDatetime? πŸ˜‰ Yeah - if it's mostly site-specific, I'd put it in a utility class. Multiple sites - probably a module πŸ™‚
  18. Craig

    Wireframe

    Something like that, yes! Use it in controllers and/or components as and when you need to πŸ™‚ If I needed more, or different, date or time functions than just "local()", I'd maybe call it "DateTimeHelper" and have various functions inside all related to date/time calculations or formatting, as I like to group similar things together. I also like to use these for getting pages for sections of the site that are repeated in different places - like news or events - and have functions like findRecent() or findByCategory(), which can accept parameters for limit, category, etc. These can then be used on homepages, sidebars, main news/events pages, or RSS. The functions interpret the parameters, set some defaults (parent, template), and make some pages()->find() calls to return the requested pages.
  19. Craig

    Wireframe

    I use Utility Classes in these cases πŸ™‚ Or you could maybe use PHP traits and use them in the controller classes?
  20. I got this too, and it seems to happen when passing fraction values to getBlurhashDataUri() - these were calculated for an image ratio (e.g. $height = $width * 0.35). If you're doing this, try passing whole numbers, or rounding the calculated dimension first (using floor, round, ceil functions): $image->getBlurhashDataUri(95, floor(95 * $ratio));
  21. You might be interested in the ReachPHP project. (Not to be confused with the React from Javascript land). It also sounds like your setup could do with some caching layers, workers, or some abstractions to manage the data you're dealing with from different services?
  22. I've used PW in mostly headless mode for a recent project at work. A new client needed to add a map of case studies to an existing bespoke site that was built by another party, and an easy way to manage them. I set up a new PW site to manage the case studies, added a basic JSON API as the only bit of front-end, and made a simple Vue app (to be embedded on the client's site) to fetch the data, filter items, and render the map/markers and detail view. Didn't take all that long to build, and the client is happy with the functionality. Each case study is associated with other bits of information, like contacts, keywords, sectors, location - and PW really made this easy.
  23. Good spot, yes. I was typing quickly πŸ™‚ What version is your MySQL server, and is there a fulltext index on the field_page_information.data column?
Γ—
Γ—
  • Create New...