CakePHP 2.x Project with unknown folder structure and database file, using EnvSwitcher Class - mysql

I have a new project that is using a plugin class called EnvSwitcher. I went to set up the database file and the database.php file is empty, except for two lines I have never seen:
App::uses('EnvSwitcher', 'Lib/EnvSwitcher');
EnvSwitcher::includeBaseFile(__FILE__);
The project does not load, only gets white screen. I tried adding the database connect info to the file, and nothing. Tried to even replace the two lines with regular database info, and still nothing. What is going on with this?

It's an Environment switching class. You are using the class here:
https://github.com/angelxmoreno/CakePHP-Environment-Switcher/blob/master/EnvSwitcher.php
Check in folder: Config/env/_default/
There should be copies of your config files there to modify.
If there is more than folder in: Config/envs, then there should be a copy of the files in each one to switch between environments.

Related

ReactJS link to local HTML file from different folder/project

I'm using ReactJS to build a site, and I want to create a link (a href="relativepath") to a local HTML file so that when the user clicks on the link, it'll open up the html page. The local file is in a different folder X outside of the project, and I don't want to upload it into my src folder because the html file depends on a lot of other files in X. Is there a good way to do so?
I also want to upload a different local HTML file that is already within the src folder of my React App. I currently have something like this:
import htmlFile from "../links/htmlFile.html"; export default function Something(props) { return (<a href={htmlFile}></a>)}
and it says in my terminal that
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <html>| | <head> >
I already tried adding in webpack + an htmlLoader, but I think I followed the steps incorrectly as I wasn't able to get it to work. I uninstalled those packages, so I'm now back to square one.
Thank you so much!
Just linking to or importing from a local file in some other location won't work unless those local files are also deployed to the server in the same location relative to the app (and the web server has access to that location).
So you'll need to copy the file and its linked dependencies in a folder that will be deployed along with your react build, but not where it'll get treated as part of the react codebase so webpack will try to compile it (so not in src either).
If you used create-react-app to set up your application, for example, this would be the public folder; other webpack setups may use different names but the general concept is the same.

Express static file is not updating

I'm running a local server with express. The server is able to display some local files from my computer. Amongst them there is a file called "lastResult.txt" which gets updated every time I run a bash script.
For some reason, when I run the server and try to display the file, it shows a version from a week ago. This file file has been updated locally more recently than a week ago. This persists even after restarting the server or even on different browsers.
I am using the serve-index module to display directories.
You didn't say how do you serve the static files - with express.static or with some custom handlers. The express.static doesn't cache the files but your custom handlers might. In any case, those files can be cached on the client depending on the value of ETag and Max-Age but even then they should not persist after accessing with another browser.
From what you're describing it seems that you are not updating the correct files, or in the correct directory. Of course it's impossible to be sure since you didn't include even a single line of your code so one can only speculate but it seems to be the case.
This question has already been answered.
I'm adding to it in case someone needs an example of a problem like this, (that is non-obvious).
Had a similar problem while using EJS and express.
I was importing a header.
The header loaded the CSS.
There was a CSS file named base.css in two different folders (same CSS file name two different folders projectroot/pages/base.css && projectroot/views/base.css )
The folder the header.ejs file was in was projectroot/views/ (this is the base.css I wanted)
From a path perspective to intentionally load the other css file should have required: ../pages/base.css
To be completely explicit I should have references the CSS file in the local directory like this: ./base.css but instead I referenced it like base.css
Surprisingly ... the CSS file that was being loaded was the one in the projectroot/pages/ directory not the projectroot/views/ directory
Changing the reference to ./base.css fixed the problem

Copy/Move files in PDI / Spoon yields 'is not a file' error

I am trying to automate weekly generation of a database. As a first step in this process, I need to obtain a set of files from network location M:\. The process is as follows:
Delete any possibly remaining old source files from my local folder (REMOVE_OLD_FILES).
Obtain the names of the required files using regular expressions (GET_FILES).
Copy the files from the network location to my local folder for further processing (COPY/MOVE FILES)
Step 3 is where I run into trouble, I frequently receive the below error:
Error processing files. Exception : org.apache.commons.vfs.FileNotFoundException: Could not read from "file:///M:/FILESOURCE/FILENAME.zip" because it is a not a file.
However, when I manually locatae the 'erroneous' file on the network location and try to open or copy it, there are no problems. If I then re-run the Spoon job, no errors occur for this file (although the next file might lead to an error).
So far, I have verified that steps 1 and 2 run correctly: more specifically, there are no errors in the file names returned from step 2.
Obviously, I would prefer not having to manually open all the files first to ensure that Spoon can correctly copy them. Does anyone have an idea what might be causing this behaviour?
For completeness, below are the parameters selected in the COPY/MOVE FILES step.
I was facing same issue with different clients and finally i tried with some basic approach and it got resolved. It might help in your case as well.
Also, other users can follow this rule.
Just try this: Create all required folder with Spoon Job "Create a Folder" and inactive/delete those hops from your job or transformation once your folders are created.
This is because, user you are using to delete the file/s is not recognized as Windows User. Once your folder is in place you can remove "Create a Folder" steps from your Job.
The path to the file is wrong. If you are running spoon in a Windows environment you should use the Windows format for filepaths. Try changing from
"file:///M:/FILESOURCE/FILENAME.zip"
To
"M:\FILESOURCE\FILENAME.zip"
By the way, it will only work if M: is an actual drive in the machine. If you want to access a file in the network you should use the network path to the shared folder, this way:
"\\MachineName\M$\FILESOURCE\FILENAME.zip"
or
"\\MachineName\FILESOURCE\FILENAME.zip"
If you try to access a file in a network mounted drive it won't work.

How can I tell PHPStorm to refactor namespaces and class names?

I've noticed when I move a file in PHPStorm, it doesn't adjust the namespace at all. My project uses PSR-0, so directory structure mirrors the namespacing. Is it possible to have PHPStorm adjust the namespace when a file is moved?
Also, when renaming a file the class name is not changed and I then have to go in and rename the class. Is it possible to rename a file and the class in a single step?
I'm using 7.1.3
I encountered the same issue. The reason was that I was trying to move the file (from project view), instead of moving the class (right click on the name in the source code).
If you use the F6 refactoring, it will allow you to move the class and change the namespace at the same time: PHPStorm docs
However, you do need to have the directory namespace mappings setup:
Because my application is a Laravel app the root directory was not the source of the namespacing. PHPStorm has a new option as of 8.0 that allows you to specify a directory as the namespace root: http://youtrack.jetbrains.com/issue/WI-22585

The connection "C:\\<path>\\*.txt" is not found. This error is thrown by Connections collection when the specific conn element is not found

I developed a SSIS package that creates several .txt files. These files are zipped and then the .txt files need to be removed. Using a foreach file enumerator, I loop through all the .txt files for a specific folder. The folder is retrieved from a variable in configuration and looks something like: C:\Folder\
The foreach loop uses: *.txt to gather all .txt files, does not traverse subfolder and uses the full qualified name.
In the Variable Mappings the "FileName" variable gets filled with the 0 index.
Within the foreachloop I use a File system task.
This task removes the .txt files which are generated before, using the FileName variable that is filled in the loop.
On the development machine this runs like a charm. All greens, no problem at all. Now I copy the package and the configuration file to the test environment. A basic version without the file removing was running perfectly fine here. I replaced the package. Nothing big.
Now I run the SQl Server Agent Job and it starts running. I can see all the text files appearing, and disappearing after it created the zipfiles. However, when all files are removed the package results with errors. Namely the error shown above in the title.
I tried looking for the connectionmanager that might have been removed
Looked for connection managers named in the config that don't exist in the package.
No such thing found. Annoying part is that the package is fully functioning, but still results with the error.
EDIT: I noticed that if I run the package using the execute package utility with the dev. config it gives the same errors.
Hopefully someone is able to help me out.
Thanks in advance!
I managed to "fix" the issue. Remove the File System Component responsible for deleting the files. Then add it again and configure it again.
I think this happens if you accidentally change General parameters before changing the Operation parameter. It holds the metadata to irrelevant parameters and upon execution says: "Wait, you defined this parameter but I don't need it, but I'm checking for it anyway, and it's not there!"
It's a bug for sure