Hi guys I want to create my own extension… I have basic app with models, controller, views and one table in DB… I already know how create simple extension (similarly like gii extension generator) but, How can I use my app in it ? What I must not forget ? And simply , how start?
I already have this
composer.json
{
"name": "tomasillo/yii2-currencies",
"description": "Showing currencies and calculating form euro to another currency",
"type": "yii2-extension",
"minimum-stability": "dev",
"keywords": ["yii2","extension"],
"authors": [
{
"name": "",
"email": ""
}
],
"require": {
"yiisoft/yii2": "*",
"2amigos/yii2-date-picker-widget": "~1.0"
},
"autoload": {
"psr-4": {
"tomasillo\\currency\\": ""
}
}
}
module.php
<?php
namespace tomasillo\currency;
Class Module extends \yii\base\Module
{
public static function run()
{
echo 'start';
}
}
?>
readme.md …
From basic yii app, my page is using model, modelsearch, cotroller, views
And of course DB, but this isn’t important in this moment
So, what to do now ? I’m beginner whit yii but it’s perfect framework so, I want to learn more
Full-blown application is not an extension. Extension is meant to be reused with any application which is not your case, it seems. If you want to start from this state for each new project, that’s application template. See how basic one made and do alike. Also check https://github.com/samdark/yii2-minimal
What for are components and why they are inside yii2-gii ?
If I’ll use in my extension/module my own model, controller and views, how can I reneder my page?. I still have problem with that. I read to many forums and now i’m really confused what I have to do… I’m doing it just for learning but I want to finish this extension, or module… or installable composer package.
Simply, my site works, I want to this page like module or …
If you can’t even sit down and read documentation, there is no way in Hell that you can create your own Yii extension.
If the 1000s of already existing Yii extensions, the excellent Yii guide and the API docs and the well-written source code is of no use to you, what do you want us to do?
You are making the classic newbie mistake of wanting to fly before you can walk.
Slow down.
Write down a list of stuff that you want to know/learn - like ‘components’, ‘models’, ‘views’, ‘controllers’ - and answer your own questions by a combination of reading the docs and writing a lot of code.
No one expects anyone to manage to jump straight into Yii extension writing - that is generally something that you can only do when you have a good handle on Yii programming.
The name of the module/extension is your-github-username[i]/your-module-name
[/i]
That is pretty much all you need to do.
Take whatever is inside your ‘modules/your-new-module’ directory and turn it into a git repository, add a ‘composer.json’ file, put it on Github and submit a package to Packagist.
If you are just testing, then you can create a local repository and tell composer about it.
The Composer part of making a Yii extension is the hard bit, unfortunately, but it is worth the effort.