How do I load the latest code in Cake REPL? - cakephp

When I make changes to my Entity code, the changes only reflect after restarting the REPL console. How do I always have the latest code in my REPL console?
./bin/cake console
> $ac_table = Cake\Datasource\FactoryLocator::get('Table')->get('AccountChannels');
> $ac = $ac_table->find()->first()
> $ac->someFunc(); // I can only see changes to this function after restarting the console
I also tried to reload the entity with the first() call after a code change, but no luck.

CakePHP uses PsySH under the hood, and currently it doesn't support code reloading, unless you can get a runkit version with import support running in your PHP environment.
Hey there's an existing fork of runkit for php7. Unfortunatly the runkit_import function was removed in version 4.0.0a1, apparently because of bugs with php7.3+, so this will not work for latest versions of php, but it should be mostly ok for earlier versions (haven't fully tested though). To install:
pecl install runkit7-3.1.0a1
I created a PR to update RunkitReloader.php class
(nb: might not work for class props, see pr modifications)
https://github.com/bobthecow/psysh/issues/416#issuecomment-776631583
https://github.com/bobthecow/psysh/issues/416

Related

Flask-Uploads Module

I am using Python 3.8.2. I am trying to create a project by using the Flask-Uploads module.
When I try to run it, I get error:
"no module named flask.ext.uploads"
I then tried to install this module again with upper case letters like Flask-Uploads, but I still have the same problem.
I was wondering if there's a problem with the latest Python version I am using?
This looks like you have a too old Flask-Uploads version.
Flask-Uploads has not seen an update on PyPi since 2016.
I created a fork of the library, in order to fix some errors and continue development:
https://pypi.org/project/Flask-Reuploaded/
You can use the new library as a drop-in replacement, that means, you do not have to change a single line of code.
Also, you have to import from flask_uploads instead of the obsolete flask.ext.uploads.

ANDROID: java.util.MissingResourceException: Can't find resource for bundle 'org.eclipse.paho.client.mqttv3.internal.nls.logcat_en_US', key ''

There seems to be countless reports of this bug in Stack Overflow. None of the suggestions worked. In my case it is almost identical to this stack overflow report
SPRING
except this case is in Android being built in Android Studio. It only happens in release mode with proguard. Proguard corrupts it somehow. And yes I have done the following in proguard:
-keep class org.eclipse.paho.client.mqttv3.logging.JSR47Logger { *; }
-keep class org.eclipse.paho.** { *; }
I have also parsed the jars downloaded by gradle. I cannot update to 1.2.1 because that only works with the latest versions of Android ... according to comments made by the developers. If I could get the source code for 1.1.0 maybe I could stop it from calling a resource that does not exist.
Anyone solve this problem or is it a bug in proguard/paho?
Looking at the apks generated by release builds (uses proguard) and debug builds (no proguard) shows that proguard is taking the org.eclipse.... package name of the properties and changing the 'org' to some letter like 'c'. The mqtt paho client is looking for the property file using the full package name and therefore cannot find it, no matter what you include or exclude in proguard. I looked at an apk made a few months ago (I have not done anything with the paho client or that part of the code using the paho client ... it has worked fine and I have had no need to change it). I see in that old release apk that the 'org' is there as it should be.
So the problem is in proguard. All I could do to move forward is take the source files for 1.1.0, create a new java project module, and tediously comment out every 'log' and getLogger in the source code. Its a temporary and unpleasant fix but it works. When proguard (R8) fixes this, then I can go back to what I had.
So I guess the only real fix is to submit a bug to R8. That I have not done.

Wakanda data browser (V1) in V 2.4.0

I've been using Wakanda since version 1. x and have been hesitating for a long time to test the newer versions because they no longer have a data browser. Now I have installed the latest version and installed a webfolder in the backend. Here I copied the complete WALIB directory and declared the Webfolder as active webfolder. Now I can use the URL "localhost: 8081/walib/dataBrowser/index. html" to access the Databrowser website, but 2 calls end with a 404 error:
"http://127.0.0.1:8081/db/walib/dataBrowser/index.package.json~waf-build.js?path=WALIB"
and
"http://127.0.0.1:8081/db/walib/dataBrowser/index.package.json~waf-build.css?path=WALIB"
It looks like the tilde is causing the problem.
How can I solve the problem, do I still have to make an adjustment somewhere?
#MyemaHMN has posted a solution that worked in this thread: Wakanda 2.2.1 Enterprise Server DataBrowser. Hope that helps.
The tilde does not seem to be the problem. In my solution I have the same call like:
http://127.0.0.1:8081/walib/dataBrowser/index.package.json~waf-build.css?path=WALIB
and it is working.
I guess it is the issue is the /db/ directory in the link. Where does it come from? The walib-directory is expected to be immediately under the webfolder.
Check the directory structure and check the app.waProject in relation to that.

AngularJS 1.5 ngComponentRouter

The ngNewRouter (now named ngComponentRouter) was supposed to be in 1.4, but was delayed and is now supposed to go into 1.5 (as I understand it). However, it's not in the 1.5 beta2 package. I do see angular1_router on github, but I don't see that built module included in the 2.0 alpha packages either.
Does anyone know if the new router will actually be in the 1.5 release?
Is there a current build of the new router hosted anywhere? I managed to find a copy of the compiled js from a random plunker, but haven't been able to compile the source myself (issues with node-gyp & msbuild, still working on that).
Does anyone know of any up-to-date documentation or working samples on the new component router? The best site I've found so far is pretty close (it says it was published in February, but it uses ngComponentRouter rather than ngNewRouter so it's clearly being updated), but the post still has things wrong - like it says to create controllers for the components you're loading for the routes, but I discovered that you actually need to be creating them as directives (optimally using the new "component" wrapper in 1.5) with the restrict set to "A" (that was fun to figure out).
You can get the new router via npm with:
npm install #angular/router
For more information on the current API you can have a look at:
https://angular.io/docs/js/latest/api/router/Router-class.html
It's for Angular 2 but the core mechanics of the router are the same, and it should give you some hints on how the API has been changed compared to the ngNewRouter.
It looks like the component router has been released. Here is the official documentation: https://docs.angularjs.org/guide/component-router
I'm not seeing any official announcements saying it was released yet though, so I'm not sure if it's supposed to be "official" or not.

Class 'SqlFormatter' is missing CAKEPHP 3 DebugKit

I've just installed the latest Debugkit from https://github.com/cakephp/debug_kit.
Everything is working. However, when I clicked on the "SQL Log", the CakePHP logo keeps spinning. I tried to debug by opening up the console.log and saw an 500 error. It shows the below.
Error: Class 'SqlFormatter' not found
File /Applications/MAMP/htdocs/App/vendor/cakephp/debug_kit/src/Template/Element/sql_log_panel.ctp
Line: 24
From my understanding, SqlFormatter class is not found in sql_log_panel.ctp. How can I add/declare the SqlFormatter class?
Just install it via composer, problem very likely solved then.
https://getcomposer.org/doc/00-intro.md
http://book.cakephp.org/3.0/en/installation.html#installing-cakephp
I highly recommend you to become familiar with composer, it is a standard tool for php developers for some time now. Composer will automatically install the dependencies for you.
Your second best option would be to download the SqlFormatter package manually from where ever it comes from and set your autoloading or include manually up.

Resources