search contents in php files in Windows 7 - php

I have spent a long time looking for a way to search a phrase across some of my php files in Windows 7.
Things I have done include:
enabling “Always search file names and contents” in Windows Explorer;
adding php in the list of “Index properties and File Contents to enable content search” in Indexing Options;
making sure the directory is indexed;
making sure I have the permission to that directory (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs).
What else should I try? Is that even possible to do that in Windows 7? If not, I’ll have to install Cygwin, which I am reluctant to do now.

Are you attempting to search the contents of each of the .php files themselves?
Or are you searching for a phrase in filenames with the corresponding .php file extension?
If your goal is the former, the following text editors can easily "Find all in open files" and even "Find all in folder(s)":
http://www.sublimetext.com/
http://notepad-plus-plus.org/
If what you're looking for is a command line option, the findstr command should serve you just fine. More information on findstr here.
If you're attempting to do the latter, then the link provided by Dany Caissy looks like it'll have just what you're looking for.

Linux/Unix has a grep command line utility for doing exactly what you want. If the built-in Win7 search/explorer capabilities don't do what you want, perhaps one of these links for third-party windows equivalents to grep:
Windows-equiv grep command line
Using Windows7 built-in findstr from command line
Note that Justice Cassel's answer has an excellent solution (search in all open files - +1 Justice), if you have your PHP files open in Notepad++. If you aren't using that NP++ for programming, you really should check it out. The FTP plugin (which automatically uploads a file every time you save it) is worth its weight, plus a dump truck, in gold.

In tools > folder options > search, you need to tick the box for always search file content.
Then when searching for a phrase e.g. "cats and dogs" you need to type the following in the search box
content:(~="cats and dogs").

Related

What is the right way to give Flatpak access to system binaries?

I'm using the flatpak version of Atom. A lot of my extentions require paths to executable binaries such as the php binary for code completion.
Now Flatpak blacklists the /usr directory, do when I pass the /usr/bin/php directory it doesn't find the proper binary even if the binary is installed and it's directory is added to the PATH environment variable of the flatpak.
So what is the correct way to do it? I've also stumbled upon flatpak versions of the binaries themselves as extentions of the org.freedesktop.Sdk package, but if I'm to use those, how do I pass them to an Atom extention that requires a path to an executable?
Addendum: I recognise that there are workarounds such as not using Flatpak Atom and using the deb package instead, or using a different IDE flatpak that has the required binaries provided, but I'm interested in a solution to this specific case.
By default the answer is no.. I saw your question went unanswered, so please try this. While this is for java, my hope is that you can try PHP... hope it helps you
However you can specify which ones you want..
Option 1:
add --filesystem=host option and then access them in the sandbox under /run/host.*
Option 2:
With Java 16 (1.16+) and later, & enable the custom Java path option
right click on the instance you wish to use Java 16 for > Click "Manage" > Enable "Custom Java Path" > And map the path to /app/jre/bin/java

Reading file and directory owner using PHP on the Windows

I have an intranet project based on the PHP and xampp server on the Windows. That intranet project have database with table where I store scanned disc drive informations of files and folders. I using simple windows command dir "$directory_path" /Q /T:C to get informations.
After that I use regex to match and parse that info to separate date, time, permission and dir name like on this example:
EXAMPLE REGEX FOR DIRECTORY PARSING
It's similar like this example: Get file owner in Windows using PHP
This working fine but sometimes file owner names are realy long and was stripped by command line. In that case I can't read full name and functionality is broken.
Now I searching for another solution.
My PHP have instaled also php_com_dotnet.dll extension and I using COM() class in some part of code.
My main question is:
-Can I use COM() class to get real file informations and avoid shell commands for the file search and listings and how?
-Is there some another extension, shell command or something 3rd what I can use to get file/folder owners?
NOTE: I need this only for the reading and indexing in the database, don't need to change permissions or ownership.
I find simple solution for this using PHP class COM() and the documentation of the IADsSecurityUtility::GetSecurityDescriptor method.
The code in PHP looks like this:
$path = 'D:\Some File\Some Another File\document.doc'; // File or dir path
$su = new COM("ADsSecurityUtility"); // Call interface
$securityInfo = $su->GetSecurityDescriptor($path, 1, 1); // Call method
echo $securityInfo->owner; // Get file owner
That's all folks.
NOTE
COM functions are only available for the Windows version of PHP.
.Net support requires PHP 5 and the .Net runtime.
As of PHP 5.3.15 / 5.4.5, this extension requires php_com_dotnet.dll
to be enabled inside of php.ini in order to use these functions.
Previous versions of PHP enabled these extensions by default.
You are responsible for installing support for the various COM objects

How to use VSCode to remotely edit website files?

I need to be able to remotely log into web servers for my clients and edit code remotely. I mostly use this for CSS changes, but also am starting to play with PHP as well.
I have tried to get Remote-Editor to work but it won't pick up the .remote file that I placed in the /home folder. The instructions don't really give great details on setting this up.
What do I do?
Use FileZilla, then set VScode as default editor (edit->settings->file editing->filetype associations and insert "php /usr/bin/code"). okey, now u need select your file on FTP and press "View/Edit", then ur file open in VScode editor. Done:)
Use an FTP client (like FileZilla), then set VSCode as the default editor. Anytime you open a file, it will open it in VSCode. I highly recommend that you download all of the code to your own computer and use it as a dev environment, and then, when you're finished with your changes, backup your site, then upload the modified files together. It's not required to edit files on your own machine, but it is recommended if you ever need to revert to an old version for whatever reason (like you made a mistake in the code, and now nothing works right).
Alternatively, you can use an extension like FTP Sync to code locally, and have the files be automatically synced for you.
Open Filezilla -> Edit -> Settings -> File Editing -> Filetype associations
Now you will have "Custom filetype associations:" situated on the right pane of the window.
Over there you have to write the command for opening VSCode for PHP files.
Step 1: Search and locate the VSCode Exe file setup install directory on your computer. In my case it was (C:\Users\Shubham\AppData\Local\Programs\Microsoft VS Code/Code.exe)
Step 2: Copy the directory path link of the ".exe" file and come back to the "Custom filetype associations:" inside Filezilla.
Step 3: Now type "php" then give space & paste the directory path that you have copied inside double quotes and then again give space and write "-open". The final code should look something like this
php "C:\Users\Shubham\AppData\Local\Programs\Microsoft VS Code/Code.exe" -open
Step 4: Click the Okay Button and have a coffee.
There are several approaches to this that are all editor-agnostic.
First, there is sshfs, which is cross-platform and you can install via your OS package manager. A simple approach would be as following:
mkdir -p ~/mnt/server
sshfs user#server.example.com:/path/on/server ~/mnt/server
Afterwards, you have the complete folder structure from server.example.com locally available at ~/mnt/server. Make sure you set up SSH keys to avoid entering the user password every time. You can find tutorials on that everywhere on the net.
For servers that only offer FTP access (shared hosting and the like), you can use curlftpfs in the same fashion.
To close the connection, simply unmount:
umount ~/mnt
For a GUI-based approach, you have several options. There is Transmit (macOS), which features mounting connections as volumes, Forklift (macOS) which is a Finder replacement that can do the same, ExpanDrive (macOS/Windows) and my favorite Mountain Duck (macOS/Windows).
If you plan to move lots of data, especially a lot of small files, Mountain Duck performs the best in my experience.
Just type this is Filezilla Settings->File Editing-> File Association
php /snap/bin/code
Open Filezilla and go to Edit >> Settings
Click on File Editing, and set the radio button to use Custom Editor
In the text field below you need to enter the full path to Visual Studio Code, this is usually found in the /usr/bin/ directory, so you need to enter the following /usr/bin/code
Next select the radio button Always use default editor and click OK to finalise the settings.
Most of the answers I see are for Windows. If anyone wants to associate File Types using Linux in Filezilla, the path is a bit different.
htm /snap/bin/code --force-user-env --no-sandbox --unity-launch
html /snap/bin/code --force-user-env --no-sandbox --unity-launch
js /snap/bin/code --force-user-env --no-sandbox --unity-launch
php /snap/bin/code --force-user-env --no-sandbox --unity-launch
You do not need to use the extra flags, but they are being used in the Menu Shortcut, so I included them.
To set VS Code as default editor for all type of files in mac use below steps:-
Click on Edit menu
Then click on setting option
Then find out File Editing and click on it (Not on submenu(Filetype associations))
Click on custom editor and then browse in application or download and select VS Code. And also click on checkbox "Always use default editor" and then click ok.
open filezilla->edit->file editing->use custom editor->browse(find the visual code path)
for find visual code path->right click on the visual code and open location and paste that location to the browse menu and find the visual code short cut
after that press ok on filzilla it will work fine
It's important that you start Filezilla as an administrator. That was the reason why it wasn't working for me.
Open Filezilla -> Edit -> Settings -> File Editing -> Filetype associations then type:
php "C:\Users\<username>\AppData\Local\Programs\Microsoft VS Code\Code.exe" %f
Note: substitute <username> with your windows username
Bonus: php can be replace with any kind of file format. Just write file extension name on lowercase.
I used this registry update to set vscode as my default text file editor (copy & paste into update.reg, open regedit and import the file):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\text\shell\edit\command]
#=hex(2):22,00,25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,41,00,70,00,70,00,44,00,61,00,74,00,61,00,5c,00,4c,00,\
6f,00,63,00,61,00,6c,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,\
00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,56,00,\
53,00,20,00,43,00,6f,00,64,00,65,00,5c,00,43,00,6f,00,64,00,65,00,2e,00,65,\
00,78,00,65,00,22,00,20,00,25,00,31,00,00,00
After that the registry is updated as follows:
Of course you should not trust hex encoded registry updates you found in the internet. So copy 22,00 ... 00,00, remove all backslashes, linebreaks and whitespaces and convert through one of many hex to ascii online converters to verify the import:
After you made this change you can even edit text files with vscode through the "edit" context menu entry:

How to add a custom file extension that has a dot (blade.php) in NetBeans?

I need to assign a custom extension to be recognized as a twig file in netbeans ('blade.php' as 'twig' file and give me syntax highlighting and code completion appropriately). The problem with using the File association option (in Tools > Options > Miscellaneous > Files)
is that it won't let me add '.' in extension like blade.php, it works with single worded extensions like php, html, css etc.
Will be grateful if anybody can help me with this!
Workaround I figured out and seems to work (at least Netbeans 8.x+)
Go to Tools > Options > Miscellaneous > Files
Click New
Enter blade as the new extension (you can use anything here, but this seems the most natural)
Click OK
In Associate File Type (MIME) select TWIG (text/x-twig)
Click OK of the whole Options window
Close Netbeans
Open the Netbeans configuration folder - on Windows it's %AppData%\Netbeans\<version>\
Go to subfolder config\Services\MIMEResolver
Open user-defined-mime-resolver.xml
Find the <ext name="blade"/> entry (or whatever you entred above)
Change the blade to blade.php
Save and close the file
Voilà, higlighting should now work in Netbeans IDE :)
Modify the user-defined-mime-resolver.xml file so that it looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.1//EN" "http://www.netbeans.org/dtds/mime-resolver-1_1.dtd">
<MIME-resolver>
<file>
<ext name="php"/>
<name name=".blade" substring="true"/>
<resolver mime="text/x-twig"/>
</file>
<file>
<ext name="php"/>
<resolver mime="text/x-php5"/>
</file>
</MIME-resolver>
On Linux (Ubuntu), you can find this file at:
$HOME/.netbeans/8.2/config/Services/MIMEResolver/user-defined-mime-resolver.xml
On Windows, you can find the file at:
%AppData%\Netbeans\8.2\config\Services\MIMEResolver\user-defined-mime-resolver.xml
Basically, the first <file> block scans the filename of any PHP files to see if it contains the ".blade" substring. If so, the file is treated as a Twig file. If not, the second <file> block will treat the file as a normal PHP file.
You might need the "Twig Templates" NetBeans plugin in order to get proper highlighting:
Tools > Plugins > Available Plugins > Twig Templates
It's not perfect... Blade directives such as #include are still highlighted as plain text. However, I feel it is a marked improvement over PHP syntax highlighting.
The following sources were extremely helpful:
HOW TO: Declarative MIME Type Resolvers
DTD Grammar Documentation
David Benedeki's earlier answer to this question
A lot of people are developing on other systems, as I am on Centos 7, so this workaround almost worked.
For CentOS, and probably other systems as well, follow these steps, almost the same as above for Windows:
Open Netbeans. Go to Tools->Options->Miscellaneous and select tab Files.
In File Extension row, click New button. Enter crazywrongname as extension name (this is important for option 2)
Below that, under Associated File Type (MIME): choose the option TWIG (text/x-twig)
click Apply and then OK.
Close Netbeans
Option 1:
The following steps are for CentOS 7 and NetBeans 8.1, most probably for other systems as well, but if you can't find the file at that path, option 2 is below.
open Terminal and open the file /root/.netbeans/8.1/config/Services/MIMEResolver/user-defined-mime-resolver.xml in your favourite text editor, e.g. run command nano /root/.netbeans/8.1/config/Services/MIMEResolver/user-defined-mime-resolver.xml
find the parameter name "crazywrongname" in this file and change it to "blade.php"
save the file
open Netbeans and enjoy.
People from the future, you might try changing the Netbeans version in file path from option 1 to yours, like 14.3 or whatever is out in 2028.
Option 2:
If you can't find this file in the exact path as above, run this command to find it:
cd / && grep -rI --exclude-dir=proc --exclude-dir=sys crazywrongname *
This will start a search for the specific pattern on your whole system, starting at root. That's why we named the parameter crazywrongname - so it isn't found in any other file on the system, like blade would be. It will also exclude the folders that are not supposed to be accessed. If you don't exclude them, you will get errors and possibly hang your system. Also, some pink unicorns might die.
After you find the exact file path for your system, follow the remaining steps in option 1 for changing the parameter name.
Thank you, mysterious David Benedeki who disappeared from StackOverflow after answer which helped enormously :)
As I can see the problem is more NetBeans-centric, so I would also suggest you to file a bug report to the NetBeans community.
The NetBeans forums.
The NetBeans bug tracker.
Maybe in the future they can fix that issue. You may also link that question so they can see the user reactions.
For module development with custom *BladeDataObject file
#MIMEResolver.Registration(
resource = "BladeResolver.xml",
displayName = "#LBL_Blade_LOADER"
)
and in the same package create the BladeResolver.xml file with the content
<MIME-resolver>
<file>
<ext name="php"/>
<name name="blade" substring="true">
<resolver mime="text/x-blade"/>
</name>
</file>
</MIME-resolver>

Activate pdf library in php - Windows (32 bit)

I have an Apache server running PHP-5.3.0 for Windows. For the creation of pdf files, I need to activate the pre-bundled pdf library (referred here) in my php by editing the configuration file. How can I do this?
Or is there any other way to enable pdf creation?
Go to PHP's root directory > php.ini. Ctrl+F 'extension=php_pdflib.dll' and remove the semicolon (;) at the start of the line. Then restart Apache. If the semicolon isn't there, then it should already be activated. If there isn't any results from the Ctrl+F, it likely means you don't have it installed. You could try adding 'extension=php_pdflib.dll' (anywhere will do).
You can use a small file to test whether the library is loaded, just write in it:
<?php phpinfo();
Watch for php.ini in the output of this script, and add the following line to the file (you may need additional privileges to do that, right click your editor -> Run as Administrator):
extension=php_pdflib.dll
Restart apache, and check that pdf has been installed by checking the aforementioned phpinfo file.
Unless you're doing really advanced PDF stuff (and you need the non-free version of php-pdf for that), I can really recommend Prince XML. It converts XML and HTML into PDF and adds additional CSS properties, like page dimensions and numbers, PDF bookmarks and the like. Their documentation is better in demonstrating that than any of their marketing pages.
I solved it using TCPDF.. Its easy to handle. No need to edit php.ini.

Categories