Use express-load in a modular mean project - mean-stack

I changed my project folder structure to use a modular approach where each functionality is grouped in folders inside "modules" directory (as defined at https://github.com/meanjs/mean).
e.g.:
How can I define express-load, since now I have more than one root directory for my models, controllers and routes?
It was previously configured all in the app directory.
e.g.:
load('models', {cwd: 'app'})
.then('controllers')
.then('routes')
.into(app);

Related

Get absolute path to directory containing current FreeMarker

In Apache FreeMarker, how can I get the absolute path to the directory containing the current .ftl file?
For example, if I was processing the file /path/to/template.ftl, then I'm searching for a way to get /path/to inside of /path/to/template.ftl.
I've tried .current_template_name and friends, but these really only contain the name of the file, not its absolute path (from which I could get the parent directory). I've also tried absolute_template_name, but this just seems to prepend the name with a / to make the path seem absolute, but it does not resolve to the real absolute path.
Background: I'm templatizing Asciidoc files with with Freemarker, and the Asciidoc files must include other Asciidoc files which reside below the original directory of the .flt file, so they must not be searched relative to the temporarily "expanded" Asciidoc file.
The template paths that templates use are always virtual, and resolved by the TemplateLoader object set in the Configuration. TemplateLoader is just an interface, has multiple implementations, and so is a black box for FreeMarker. The actual location of the template can be inside a jar file, or even in the database table, so in general a template has no path on the file system.
Normally, you set up the TemplateLoader so that it can access all the templates you need. Then you don't need any tricks, and just use template paths.
Another possibility is to use a FileTemplateLoader that uses the root directory as base directory. This of course would be a bad idea for most applications (especially for web applications, for security reasons).

Create a folder inside the component folder laravel

I have a project that will contain a lot of components, however I want to divide the folder of components into section as you can see:
However when I use the component inside the test folder I'm getting an error:
View [components.admin-panel-main-navbar] not found
How can I fix this issue?
You may use the . character to indicate if a component is nested deeper inside the components directory. For example, assuming the component is defined at resources/views/components/inputs/button.blade.php, you may render it like so:
<x-inputs.button/>
https://laravel.com/docs/8.x/blade#anonymous-components
So in your case
<x-test.admin-panel-main-navbar/>

Where does one place Models in a Laravel Package?

I'm currently following the Laravel Package documentation, which uses the workbench tool to create a standard package tree consisting of controller, config, views, etc. folders. Basically, most folders you would get in a standard Laravel app tree.
However, I had a couple of questions:
Why is the models folder absent here? (though the same goes for tests and commands)
Should I just create the folder myself and add it to the composer.json autoload classmap?
What classes should live inside src/<Namespace>/<PackageName>? I have noticed that a ServiceProvider is automatically created here, but I can imagine most other files just existing in the standard package directories.
Wockbench represents just a tool for creating other tools, that is triggered through CLI. Workbench is very abstract concept.
Model folder is absent simply because you don't need model in every new package. For example, if you are creating middleware package or you own filter package.
Every new class can be added to package dependent on its purpose and responsibility. It can be done in more then one way.
Classes that are general enough to go into every package are:
Package Service Provider
Facade
Basic Class
But it is not a black box. Consider for example request class - it is bound very early in the application life cycle, so no provider is needed.

Can I extend the core helpers within a package in Code Igniter?

I'm building my own base to use on multiple sites that I will be building. And I've made a package for that. But I want to extend the CI helpers in that package (not in the app) - helpers such as url_helper, html_helper etc.
I've put a config folder (although I don't really understant what it does) in the package folder and a config file in it (so structure is packages/app_package/config/config.php).
I've put the $config['subclass_prefix'] = 'app_'; (different from the application one preferably) and still not loading the helpers app_url_helper etc
Did anybody do that?
Have a look at CodeIgniter Helpers. Specifically the section labelled "Extending" Helpers.
I'm not quite sure what you mean by:
I've put a config folder (although I don't really understant what it
does) in the package folder and a config file in it (so structure is
packages/app_package/config/config.php).
You're not required to 'create' any config folders or files at all. The config file already exists and is located in application/config/config.php of your CodeIgniter project. The Class Extension Prefix is located ~ line 110 (version dependent). Set it to _app
Now create app_url_helper.php and app_html_helper.php in application/helpers and away you go.

How to include file from the "library" fold in Zend

In Zend, inside the "Library" folder, I have a PHP file that I want to include in another file. How do I do that?! I cannot figure out the root to the library folder.
How about study some documentation about Zend autoloading capabilities. There are plenty of options, how to autoload files,which contains php classes.
here you go http://framework.zend.com/manual/en/zend.loader.html
But if you want it plain and simple :
every zend application generated with zf tool should have defined APPLICATION_PATH constant, which is pointing into application folder. So you could use it for constructing absolute path to file
define namespace inside config, e.g. Autoloadernamespace[] = 'Custom_'. Then if you create inside library class file ./library/Custom/Object.php with class Custom_Object, Zend loader loads this file when you will be creating instance of Custom_Object class (or call static method)
RTFM, there are other things possible ...

Resources