Giter VIP home page Giter VIP logo

Comments (9)

ThinkDevStudios avatar ThinkDevStudios commented on August 24, 2024

Got it working now.

from theme.

jlambe avatar jlambe commented on August 24, 2024

@rovillesarate Can you please post your solution? because it seems I've made a mistake regarding PSR figure.

from theme.

jlambe avatar jlambe commented on August 24, 2024

@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.

ThinkDevStudios avatar ThinkDevStudios commented on August 24, 2024

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.

jlambe avatar jlambe commented on August 24, 2024

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.

ThinkDevStudios avatar ThinkDevStudios commented on August 24, 2024

do i need to still edit the loading config file to be able to use namespace?

from theme.

ThinkDevStudios avatar ThinkDevStudios commented on August 24, 2024

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.

ThinkDevStudios avatar ThinkDevStudios commented on August 24, 2024

Got it working already. Its use Themosis\Facade\Page;

from theme.

jlambe avatar jlambe commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.