I want to install Select 2 extension widget manually with Yii2 Framework without using composer.
I done the following steps but it's not working.
1) Added yii2-widget-select2 to vendor/yii-soft
2) Added following code in my yii-soft/extensions.php:
'yiisoft/yii2-widget-select2' => array(
'name' => 'yiisoft/yii2-widget-select2',
'version' => '2.0.3.0',
'alias' =>
array(
'#yii/kartik' => $vendorDir . '/yiisoft/yii2-widget-select2',
),
),
3) Added display in view form:
use kartik\select2\Select2;
<?php echo Select2::widget([
'model' => $model,
'attribute' => 'state_2',
'data' => $data,
'options' => ['placeholder' => 'Select a state ...'],
'pluginOptions' => [
'allowClear' => true,
],
]); ?>
And It shows the following error:
PHP Fatal Error – yii\base\ErrorException. Class
'kartik\select2\Select2' not found
It's highly recommended to use composer instead.
But if you want to do it manually:
1) Download archive of needed version from Github.
2) Open composer.json.
3) Find PSR-4 autoload section and remember it, in your case: kartik/select2.
4) Extract files to corresponding folder in vendor: vendor/kartik/select2 (not yiisoft!).
5) Add to vendor/composer/autoload_psr4.php:
'kartik\\select2\\' => array($vendorDir . '/kartik/select2'),
6) Add to vendor/yiisoft/extensions.php:
'kartik/select2' => array (
'name' => 'kartik/select2',
'version' => '2',
'alias' => array (
'#kartik/select2' => $vendorDir . '/kartik/select2',
),
),
samdark, one of the core contributors has the article in russian about it on his official blog here. It's basically brief translated version.
As you can see it's quite a lot of work to do. Multiply it by number of extensions and it becomes pain.
Seriously, use composer. If the hoster doesn't support it, find another one.
You can use yii2-workbench package. It designed for easy intergrate package without composer. It support composer autoload and bootstrap
It is subrepository .GIT , delete .git from vendor\kartik-v\yii2-widget-select2 and git rm --cached yii2-widget-select2
Stash, Commit,Push.
Related
I'm writing a package on laravel that it require some packages to install.
I want to overwrite own package configuration file with the applications's published copy, and use the mergeConfigFrom method within my package service provider's register method. but it dosent work as i expect
app/config/publishedConfig.php
return [
'dashboard_url' => 'home',
'logout_url' => 'logout',
'login_url' => 'login'
];
And
package/vendor/path/to/config/config.php
return [
'dashboard_url' => 'dashboard/login',
'logout_url' => 'dashboard/logout',
'login_url' => 'mongodb-login'
]
Then in register method on my package service provider i use mergeConfigFrom like below to overwrite publishedConfig on run time:
public function register(){
$this->mergeConfigFrom(
__DIR__.'/config/adminlte-logo.php','publishedConfig'
);
}
After that I use dd(config('publishedConfig')) helper to get result of merge But the result not changed.
expected result is :
'dashboard_url' => 'dashboard/login',
'logout_url' => 'dashboard/logout',
'login_url' => 'mongodb-login'
I will appreciate anyone who solve my issue.
Thanks in advance
Finally i have overwrite it in --force tag way.
php artisan vendor:publish --tag=config --force
I am trying to work with fluidxml to test if I can use it, but I cant get it to start working, I am using codeigniter framework. I cloned the repo https://github.com/servo-php/fluidxml and added it to a folder I created called thirdparty. Then here is the code for the function
public function xmltrial(){
$this->load->helper('file');
require_once(APPPATH.'third_party/fluidxml/source/FluidXml.php');
$book = new FluidXml();
$book->add([ 'title' => 'The Theory Of Everything',
'author' => 'S. Hawking',
'chapters' => [
[ 'chapter' => [
'#id' => '1',
'#' => 'Ideas About The Universe' ] ],
[ 'chapter' => [
'#id' => '2',
'#' => 'The Expanding Universe' ] ],
]]);
echo $book;
}
So I am getting two errors , one is Fatal error: Class 'FluidXml' not found even and the second one is if I use use function \FluidXml\fluidxml;
use function \FluidXml\fluidns;
use function \FluidXml\fluidify; all this character inside my xmltrial function it shows a red error on them.
You should use composer to manage your dependencies. Get composer installed, then install FluidXml into the vendor folder by typing
composer require servo/fluidxml
in the command line. Then you can
require_once 'vendor/autoload.php'
in your index.php, and you can forget about having to require in the files! You just need to put the relevant use statement under your namespace declaration.In your case,
use FluidXml\FluidXml;
Now you can start calling your class!
See Packagist for composer package details https://packagist.org/packages/servo/fluidxml
See Composer site to get composer into CodeIgniter if you don't already https://getcomposer.org/
Helle ZF2 Guru! Normally we get the zf2 translation file from a directory in Appliction module.config.php like this: 'base_dir' => DIR . '/../language' .
Is it possible to get it from a Uri?
Application module.config.php:
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',//http://example.com/
'pattern' => '%s.mo',
),
),
),
Why this is important?Correct me if I am wrong! In a multilingual application, language files are static files and for a real world application any static files better be on cloud like AWS CloudFront or CDON for better performance of Application and longer caching period.
I don't think this way is possible and I think it's not interresting to have this file outside the App directory because it's a part of your PHP software which will be interpreted and "compiled" by your web server at each HTTP request.
It's interresting for a JSON file downloaded by the navigator with AJAX request for example because the navigator will store the file in cache.
Our solution was to determine what is the current language in application.config.php:
define ('SITE_LANG', ...);
In our case it was simply the first two letters of the path:
www.site.com/en/...
Then in module.config.php:
'translator' => [
'locale' => SITE_LANG,
'translation_file_patterns' => [
[
'type' => 'phparray',
'base_dir' => 'vendor/zendframework/zendframework/resources/languages/',
'pattern' => '%s/Zend_Validate.php',
],
and it did the trick.
DISCLAIMER: I'm a complete noob to Zend.
I'm evaluating Zend Framework 2 at work, and trying to configure it to work with ZfTwig for templating. (See here: https://github.com/mtymek/ZfTwig)
I got through Step 3 of the config ok, but I can't figure out Step 4.
I tried placing the following in application.config, but no good.
Where am I supposed to put this?
return array(
'di' => array(
'instance' => array(
// setup other stuff...
// ...
// setup view script resolvers - very similar to configuration
// from ZendSkeletonApplication
'Zend\View\Resolver\AggregateResolver' => array(
'injections' => array(
'Zend\View\Resolver\TemplateMapResolver',
'ZfTwig\TemplatePathStack',
),
),
'Zend\View\Resolver\TemplateMapResolver' => array(
'parameters' => array(
'map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.twig',
),
),
),
'ZfTwig\TemplatePathStack' => array(
'parameters' => array(
'paths' => array(
'application' => __DIR__ . '/../view',
),
),
),
// Tell TwigRenderer how it should locate .twig files
'ZfTwig\TwigRenderer' => array(
'parameters' => array(
'resolver' => 'Zend\View\Resolver\AggregateResolver',
),
),
),
);
Google is no help... I can't find any documentation on Zend's site or anywhere telling me where this is supposed to go.
Thanks for the help!
The di configuration is from the first betas of Zend Framework 2. Zend\Di is a component still available, but internally (as with many other modules) replaced by Zend\ServiceManager.
Basically, both are able to provide dependency injection. Only for Zend\Di it can do this kind-of automatically and for Zend\ServiceManager there are other options to make dependency injection more explicit.
To give an answer to your question: ZfcTwig is now part of ZF-Commons and https://github.com/ZF-Commons/ZfcTwig is the location you have to search for now. Just for your insights, this file is an example of a factory used by the service manager. For more background of service managers in Zend Framework 2, I have written a blog post two months ago which might be interesting.
I've created a module, a basic copy of the the albums example given in the ZF2 documentation, however, with the new module, I am not able to access it at all - I'm always given a 404 error. I'm building this on the ZF2 skeleton.
I've got three modules loaded: Application, Frontend and Security.
Both Frontend and Security are duplicates of each other, however, I have thoroughly checked and there is no reference to old code (as I literally copied the module folder and renamed/rewrote references).
The module is also loaded in application.config.php.
Any ideas on what I'm missing?
Module Config:
return array(
'controllers' => array(
'invokables' => array(
'Security\Controller\Security' => 'Security\Controller\SecurityController',
),
),
'router' => array(
'routes' => array(
'security' => array(
'type' => 'segment',
'options' => array(
'route' => '/security[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Security\Controller\Security',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'security' => __DIR__ . '/../view',
),
),
);
I had the same problem while following the skeleton application tutorial (Getting started: A skeleton application). Whenever I would go to the album url in the browser (ZendSkeletonApplication/public/album in my case), I would get a 404 error page but no details on why I got the 404. It wasn't clear to me how I would be able determine why I was getting the 404 when I had double checked everything and was pretty sure I copied and configured the Album module properly. It turned out that I was missing a slash in my route (module.config.php). For example I had 'route' => 'album[/:action][/:id]' instead of 'route' => '/album[/:action][/:id]'.
I was only able to figure it out by intentionally causing errors by misspelling things like making the 'Album\Controller\Albums' instead of 'Album\Controller\Album'in the invokables value, this would cause a stack trace to display which then showed the ZF2 classes that where called on the request. I would continue to misspell, test, and then correct each part of the module.config.php until I was given a clue to what part of the configuration was causing the error.
I'm pretty sure this was not the best way to debug an application's configuration.
There is few things that need to be make sure is:-
You have to add your module in
application.config.php (which you are saying you done it.)
Security\Controller\Security has to be same in default too (which you already has)
One more thing is Your folder structure....
-
Just to doulbe check you have a /MODULE/src/MODULE/Controller/CONTROLLER_FILE_NAME.php
I hope that helps..
I know it is an old post. However another thing to make sure you have in the modules top directory (same directory as the Module.php file) is the "autoload_classmap.php"
file with "<?php return array();?>" inside of it.
A simple tip to know whether your rule has already added correctly to the routes or not, you may check the routes value in the config file inside any working module, as following:
$config = $this->serviceLocator->get('config');
var_dump($config);