Comments (9)
Got it working now.
from theme.
@rovillesarate Can you please post your solution? because it seems I've made a mistake regarding PSR figure.
from theme.
@rovillesarate Can you post your class namespace and the code from your loading.config.php file? Apparently, it's not psr-4 autoloading, but psr-0. It seems that I misunderstood the symfony api. Have you created extra folders to make your model class working?
from theme.
Yes. I also figure out that it is not using psr-4.
In the loading.config.php
return [
'MyTheme//' => [themosis_path('theme').'controllers', themosis_path('theme').'models']
];
Its not working when i try to use it as
namespace MyTheme/Models/ or MyTheme/Controller or just
namespace MyTheme since in the loading.config we already specified the directory to the controllers and model. It cant seem to be able to find the class no matter what you do. So if you try to call it
use MyTheme/Models/MyModel; MyModel::function(); It says it cant find the class name.
so I end up removing the key in the loading config. I also found out that the model and controller file name should be the same with its class name or it wont be recognized.
Plus i also forgot that my functions are not static functions so calling it by Class::function() wont work.
from theme.
I've just released framework 1.2.1 with appropriate fix to use psr-4 autoloading. Make sure to run a composer update
then copy/paste the bootstrap/start.php
file located in the new themosis-theme (1.2.1) into your custom theme.
You should be able to use classes with or without namespaces correctly now.
Thanks for reporting this. Regards,
from theme.
do i need to still edit the loading config file to be able to use namespace?
from theme.
What is the namespace for Page::make() ?
use Themosis\Page; ? i am having problem with just the Page::make() If i remove it everything works fine.
from theme.
Got it working already. Its use Themosis\Facade\Page;
from theme.
If you want to namespace your custom classes, yes, you need to update your loading.config.php
by specifying your namespace as the key and your class paths as value.
All core classes work base on a facade as you found. Basically the Page API class fullname is Themosis\Facades\Page
. But in order to simply use it as Page
, the framework defines class aliases.
You can define custom aliases for your classes as well. For example, let's say you have a PageModel.php
class inside your models with a namespace of MyTheme
, the class fullname is MyTheme\PageModel
. Now let's say you want to use that model under the Pm
name, you'll define an alias in your application.config.php
file like so:
[
'MyTheme\\Models' => 'Pm'
]
from theme.
Related Issues (20)
- Testing your theme's code HOT 1
- Pronto class not available HOT 2
- change font source url(s) to avoid http/https conflicts
- Conditional filter HOT 2
- WordPress models HOT 3
- Customize register
- Shortcode HOT 1
- Add config file HOT 2
- Widget render form admin HOT 1
- Overloading config with child Themes. HOT 1
- How to use woocommerce template files?
- themosisRouteConditions filter isn't accessible from admin directory HOT 5
- Themosis and Child Themes 1.3 HOT 2
- Loading SVG file to media field HOT 5
- UnitTest HOT 3
- Shortcodes with Twig template HOT 4
- Kernel instantiation is not handled as a singleton HOT 2
- No gulpfile found HOT 2
- Wrong config format sent to $theme->images HOT 2
- Disable part of themosis routing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from theme.