PHPStorm: Syntax Highlighting for PHP code inside XML tags - syntax-highlighting

Is there any way to make PHPStorm apply syntax highlighting to PHP code inside a tag in an XML file?
I'm working on an OpenCart project and I'm using Vqmod, which requires that I write PHP code in an XML file. For example:
<operation>
<search position="replace"><![CDATA[
<?php echo "123"; ?>
]]></search>
<add><![CDATA[
<?php echo "xyz"; ?>
]]></add>
</operation>

1) Settings | File Types -- assign *.xml (or whatever file name pattern you think is more appropriate) to PHP files entry (you may need to remove it from "XML files" first).
This will tell PhpStorm to treat such files as PHP (it's the only way to have PHP support).
The possible negative side -- it's an IDE-wide setting and will affect ALL such files in ALL projects. Therefore -- if you can name such files in some unique way (e.g. double extension: *.php.xml or *.xml.php; unique extension: *.pxml; unique file name ending: *layout.xml) then do it.
2) Settings | Template Data Languages -- find such files (or whole folder) and assign XML in 2nd column.
This will tell PhpStorm to treat such files as "PHP with XML" instead of default "PHP with HTML".
Official manual: http://confluence.jetbrains.com/display/PhpStorm/Syntax+highlighting+of+PHP+inside+JavaScript+%28and+other+languages%29

Related

sphinx documentation - excluding rst files that begin with a specific character?

I work on page drafts in my sphinx doc that I don't want to be available when I run sphinx-build.
for example I have files named _bob.md , _mistbuddy.md etc.
in my conf.py file I put:
exclude_patterns = [ '**/_*']
to ignore these file.
This works on load - files ignored :
However, if I then click on one of the topics, and ALL pages are available.
I have tried .. only:: <tag> however, a directive doesn't work on all contents in a file.
Thank you.

How to STR Replace and echo in laravel

Files that are uploaded to my site have their names changed and extention change to bin. So for example a uploaded file will be dfd84848.bin, using the bin file worked fine with modelviewer but im trying to test babylon.js and it doesnt work with .bin only if i change .bin to .glb.
This code {{uploaded_asset($detailedProduct->cad_file)}} provides link like uploads/all/p1YZX9TBc7EmimFx4rXnSFKvVor8EttpOUUpylLL.bin
I want to change .bin to .glb and echo it.
i tried this
#php
$previewfile = uploaded_asset($detailedProduct->cad_file);
$replaced = Str::replace('.bin', '.glb', $previewfile );
#endphp
to show i used this <model url="{$replaced}"> but it never echoed url
Edit
So now that it echos as name.glb it doesnt work because the file doesnt exist on server. When 3d models such as .glb, .gltf are uploaded they are renamed to .bin i dont know why. The uploader is AizUploadController.php
To echo a value you should use double curly braces:
<model url="{{ $replaced }}">
Docs: https://laravel.com/docs/8.x/blade#displaying-data

How to read a .docx file via PHP Word sample code in Codeigniter

Am trying to read a .docx file which is inside my project folder via PHP Word library. I have included autoloader like this :
include_once 'vendor/autoload.php'; in my controller.
CODE FOR FUNCTION IN CONTROLLER:
function test_phpword()
{
$a=base_url();
$path=$a."".'123.docx';
$source =$path;
echo date('H:i:s'), " Reading contents from `{$source}`";
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source);
echo write($phpWord, basename(__FILE__, '.php'), $writers);
}
BUT GETTING ERROR LIKE BELOW:
06:18:42 Reading contents from http://localhost/myproject/123.docx
Fatal error: Uncaught Exception: Cannot find archive file. in /opt/lampp/htdocs/myproject/vendor/phpoffice/common/src/Common/XMLReader.php:51
Try this
Change
$path=$a."".'123.docx';
to
$path='123.docx';
And put 123.docx beside your php script file. make sure the two files are in the same place. Run your php script again.
If this helps and works fine you can check the file path and make proper change to your php program.
While loading the path, you have to give relative path to the doc file as shown below,
$random_name = 123.docx;
$contents = \PhpOffice\PhpWord\IOFactory::load('../uploads/'.$random_name);
I don't know whats your $base_url, but it will not work if it is absolute path like http://path/to/doc/file.
I have worked on it and tested. Hope it helps.

Use multiple env files

I'm wondering if there's a way in Laravel to specify a set of env files to load. My exact problem is I want to add something like a suffix to all my .js and .css resources. Ideally I'd have a suffix like the release date because it would be ok for these files to be cached within the same release but I would like the caches to be invalidated on the next release. However I want to avoid reading, modifying and saving the .env file if possible and would instead prefer to create a new file e.g. .env.rdate which would be generated via a script, e.g.
echo APP_RELEASE_DATE=`date +%s` > env.rdate
or something like this. Is this at all possible or do I have to read/update/write the .env file instead?
Create your .env.rdate file next to .env file.
Put this to your AppServiceProvider boot method:
$dotenv = new \Dotenv\Dotenv(base_path(),'.env.rdate');
$dotenv->overload();
After you can use in your project:
ENV('APP_RELEASE_DATE')

Laravel 5 Elixir source and output pathing

I'm having trouble understanding Laravel 5's elixir pathing. In my project, I have multiple css files (bootstrap, plugins, theme etc) and javascript files stored under:
resources/assets/css/<my css files>
resources/assets/js/<my javascript files>
I simply want to combine and version all styles and scripts and place them in my public directory. I believe the default output directly is:
public/build/css/app-xxxxxxxx.css
public/build/js/app-xxxxxxxx.js
(Where xxxxxxxx is the checksum using the version method)
What should my gulpfile.js look like to achieve this? Thanks!
You can use full path on the name or set the third parameter as default path. Examples (works with scripts or css):
mix.stylesIn('resources/assets/css', 'public/css/all.css');
Since there is a bug where you can't use the output of a somethingAll to concatenate with something else, I use this instead (note the wildcard):
mix.scripts(['maskedinput.js',
'blockui.js',
'user/*.js'],
'public/js/user.js', 'resources/assets/js/');
First parameter is the input files, second is the output file, third is the input's default path.
To version just call it on the file path.
mix.version("public/js/user.js");

Resources