bernhard Posted January 24, 2021 Share Posted January 24, 2021 The PW core comes with many great classes such as WireData, WireArray and so on. Sometimes I'm developing stuff without a running PW instance and I'd love to have the great PW api available there as well. I've mentioned that in the PW Roadmap 2021 thread and Ryan stated: https://processwire.com/talk/topic/24897-weekly-update-– 8-january-2021/?do=findComment&comment=209891 Spoiler On 1/11/2021 at 5:10 PM, ryan said: Quote Examples of such classes that might be useful even without a DB connection could be: With the exception of WireMail, all the classes you mentioned are intended to be available for standalone use. Though it's been a long time since I've used any of PW's classes in that way. This I think is likely an easily attainable thing to support though. Most of the mentioned classes just extend the Wire class, making it the only dependency (and Wire doesn't require a DB connection). Quote There's no reason why we need a running PW instance with a DB connection for such a code example. Of course I know that it's technically required in many places in the core, but maybe these places could be identified and removed in the future?! A DB connection would be needed for WireMail because it is a module type. Installed modules are known from the database modules table. A WireMail module also maintains its settings in the database. Now is is true that the base WireMail class can operate without a database, but WireMail is only useful because it is a module type. Take out the module aspect and WireMail is just an interface to PHP's mail(). That sounded interesting, so I've tried how that works and created a repo for quick and easy testing so that everybody can try what works and share their findings so that everybody can learn. https://github.com/baumrock/PwStandalone PwStandalone The ProcessWire core has many great classes such as WireData, WireArray, WireRandom etc.; Many of them can be used without a running PW installation! This repo helps testing those features and hopefully will motivate others to share their findings (as PRs). It's as simple as creating a new file in the examples folder! I'd appreciate any help regarding the examples throwing an error! PRs for other examples that you've tried very welcome! 12 Link to comment Share on other sites More sharing options...
bernhard Posted April 15, 2022 Author Share Posted April 15, 2022 Actually it's a lot easier! // /path/to/pw/root/standalone.php <?php namespace ProcessWire; require "wire/core/ProcessWire.php"; $data = new WireData(); $data->foo = 'foo'; $data->bar = 'bar'; echo print_r($data->getArray()); // execute the script cd /path/to/pw/root php standalone.php How great is that? ? 1 Link to comment Share on other sites More sharing options...
eydun Posted November 15, 2023 Share Posted November 15, 2023 Would it be possible to use WireHttp as standalone? https://processwire.com/api/ref/wire-http/post/ Link to comment Share on other sites More sharing options...
nurkka Posted November 12 Share Posted November 12 I wonder if it would be possible to use a standalone ProcessWire to import a database dump. As I am using RockShell, one has to initially use phpMyAdmin or adminer etc. to import the database once. After that, RockShell is able to import database dumps. Would be great to have the possibility to omit the manual step and only use RockShell. Does anyone know, if this could be achieved with a standalone processwire, like described by @bernhard? Link to comment Share on other sites More sharing options...
bernhard Posted November 12 Author Share Posted November 12 @nurkka RockShell can run without PW, but not all commands. Most need PW to be installed, but often that's just necessary (because it makes no sense without) or convenient (because it's harder to develop something without having PW magic on board). What you describe makes sense and it is definitely on my list. If anyone finds time to add this I'd be super happy to add it. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now