DatePicker issue in yii2 - php

Hello I have installed date time picker from "https://github.com/2amigos/yii2-date-time-picker-widget"
I have put this into vendor/amigos/yii2-date-time-picker-widget-master
I have added following lines in my composer.json
"amigos/yii2-date-time-picker-widget" : "*" in require section
so it is finally
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"amigos/yii2-date-time-picker-widget" : "*"
},
but when I write following code,
<?= DateTimePicker::widget([
'attribute' => 'created_at',
'language' => 'es',
'size' => 'ms',
'clientOptions' => [
'autoclose' => true,
'format' => 'dd MM yyyy - HH:ii P',
'todayBtn' => true
] ]);?>
It says "Class 'DateTimePicker' not found"

for me it is working fine, it looks like you are missing some dependency.
So I think you should update Yii using composer(if composer is
installed) for example if you are using windows then go to ur
project directory in command prompt and run
composer update --prefer-dist
This should update all the dependencies include in your
composer.json.
Another point is that in my installation the folder is named as
2amigos instead of just amigos in every places please try changing the folder
name if that works.

Change it to right name:
2amigos/yii2-date-time-picker-widget
And then you have to update your autoloader:
composer dump-autoload

try adding
"2amigos/yii2-date-time-picker-widget" : "~1.0"
to composer.json file and update composer using
php composer.phar update

Reference: https://github.com/2amigos/yii2-date-time-picker-widget/issues/9#issuecomment-156999145
As bootstrap-datetimepicker is not registered in packagist.org, it is showing this error.
We can do following:
Steps:
Install smalot-bootstrap-datetimepicker#2.3.1 using following command
bower install smalot-bootstrap-datetimepicker#2.3.1
This will copy required files in \vendor\bower\smalot-bootstrap-datetimepicker directory.
Clone https://github.com/2amigos/yii2-date-time-picker-widget.git
Remove "bower-asset/smalot-bootstrap-datetimepicker": "2.3.1" from composer.json.
It should look like this after removing
"require": {
"yiisoft/yii2": "~2.0",
"yiisoft/yii2-bootstrap": "~2.0.0"
},
Commit changes using
git add .
git commit -m "remove dependency."
Update yii2's composer.json to following:
"repositories": [
{
"type":"vcs",
"url":"file://D:\\programs\\xampp\\htdocs\\ppd\\packages\\yii2-date-time-picker-widget-master"
}
],
"require": {
...
"2amigos/yii2-date-time-picker-widget": "dev-master"
},
Please change url according to path where you have cloned repo.
run composer update --prefer-source.
Now datetimepicker widget is installed.

How did you installed it? Don't try to download it and copy it into vendor.
https://github.com/2amigos/yii2-date-time-picker-widget
Installation
The preferred way to install this extension is through composer.
Either run
composer require 2amigos/yii2-date-time-picker-widget:~1.0
or add
"2amigos/yii2-date-time-picker-widget" : "~1.0"
to the require section of your application's composer.json file.
run
composer install

STEP -1
Run this command on Terminal at Project main folder
---->curl -s http://getcomposer.org/installer | php
STEP -2
Successfully installation after run this command
--->php composer.phar require kartik-v/yii2-widget-datepicker "*"
you can see this contant in advanced->composer.jason file
"kartik-v/yii2-widget-datepicker": "*"
If you can't see , you can missing some...
STEP -3
Define this library in views-> _form.php
use kartik\date\DatePicker;
STEP -4
And last define this given below code in your form at date field
<?= $form->field($model, 'xyz_field')->widget(DatePicker::ClassName(),
[
'name' => 'check_issue_date',
// 'value' => date('d-M-Y', strtotime('+2 days')),
'options' => ['placeholder' => 'Select issue date ...'],
'pluginOptions' => [
'format' => 'yyyy/dd/mm',
'todayHighlight' => true
]
]);?>

I suggest use the HTML DatePicker, it doesn't have problems and its easily to use
<?= $form->field($model, 'date_of_birth')->textField(['type' => 'date']);?>

Related

Geolocation package with laravel: Midnite81\Geolocation\GeoLocationServiceProvider' not found

I want to use the following package for geolocation with laravel.
https://github.com/midnite81/geolocation
I have done everything they wrote in their documentation but find an error
Midnite81\Geolocation\GeoLocationServiceProvider' not found
i am unable to solve this problem. Can't understand what's wrong. What i did, at first, write "midnite81/geolocation": "1.*" in the composer.json file.
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"midnite81/geolocation": "1.*"
},
After that run composer update. Then run composer dump-autoload -o. Then in the config/app.php file, put the following part in providers and aliases array.
'providers' => [
Midnite81\Geolocation\GeoLocationServiceProvider::class
];
'aliases' => [
'GeoLocation' => Midnite81\GeoLocation\Facades\GeoLocation::class,
];
then run the following command.
php artisan vendor:publish --provider="Midnite81\GeoLocation\GeoLocationServiceProvider"
Then got the error, Midnite81\Geolocation\GeoLocationServiceProvider' not found
Can't figure out what's wrong in it.
I verified and confirm the problem.
The problem is:
Midnite81\Geolocation\GeoLocationServiceProvider::class
You should change this into
Midnite81\GeoLocation\GeoLocationServiceProvider::class
Notice the difference Geolocation vs GeoLocation. It seems there is error in readme for this package on Github
I've already sent Pull request https://github.com/midnite81/geolocation/pull/2 to fix readme for this package

Laravel 5.2 - Adding laravelcollective/html 5.2 throws errors

I'm using Laravel v5.2 and have followed the instructions below to install laravelcollective/html, but it still throws errors:
Browser: FatalErrorException in ProviderRepository.php line 119: Call to undefined method Collective\Html\FormFacade::isDeferred()
Artisan: [Symfony\Component\Debug\Exception\FatalErrorException] Call to undefined method Collective\Html\FormFacade::isDeferred()
Also tried 5.2.*-dev, but get the same errors.
Hope someone can help!
Command:
composer require laravelcollective/html
Added to composer.json "require" group:
"laravelcollective/html": "5.2.*"
composer update
Added to config/app.php in providers group:
Collective\Html\HtmlServiceProvider::class,
In aliases group:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
I hope it is not too late, but maybe answer on your question will be useful for a future reference. So, here is step by step:
1) In the root of your laravel package open composer.json file in "require" group should be added this line:
"laravelcollective/html": "5.2.*"
It should look similar to:
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.",
"laravelcollective/html": "5.2."
},
2) Open command prompt or Git Bash and update the composer with command:
composer update
The composer will update within about one or two minutes.
3) Open config/app.php add this line in providers group:
Collective\Html\HtmlServiceProvider::class,
and don't forget to separate the previous class by comma. It should look like:
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
4) In the same file in aliases group add these alias:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
so it should look like:
'View' => Illuminate\Support\Facades\View::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
I hope this will help to anyone who use Laravel 5.2.*

How to install "vinelab/http" in laravel 5

I am following the documentation at
https://packagist.org/packages/vinelab/http
My composer.json :
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"laravelcollective/html": "~5.0",
"vinelab/http": "dev-master"
},
my app.php in config
'providers' => [
...
/*
* Helpers from packalyst.com
*/
Vinelab\Http\HttpServiceProvider::class
],
'aliases' => [
...
/*
* Helpers from packalyst.com
*/
cURL' => Vinelab\Http\Facades\Client::class
],
Following all the steps diligently.
I run php composer update and get this error.
http://goo.gl/sOj2gG
I am a novice in laravel and composer and am learning my way through.
Thank you for the help guys !
It seems that you have Zjango package in your service provider, but your composer.json file doesn't seem to show it. It is trying to load a service provider that hasn't been loaded via composer.json.
try adding "zjango/laracurl": "dev-master" to your composer.json file and run composer update again.
You have to install the composer package before putting in the service provider.
Remove the provider from the array in config/app.php.
Run composer update.
Put the provider back into the array in config/app.php.

Custom Laravel Directory Install With Composer

I was wondering if it was possible to create a custom laravel "template" with composer.
For example, I want to include in my composer's create-project laravel/laravel install these two extensions by default,
https://github.com/briannesbitt/Carbon
https://github.com/maxhoffmann/parsedown-laravel
or additional folders in the root directory so I don't have to re-create them each time.
I don't mean to ask how to install those ^ above,
but I mean to ask how to set it up so that
when i run
composer create-project laravel/laravel projName
It automatically has those files/extensions/etc
created and/or installed
Just add maxhoffmann/parsedown-laravel in your composer.json file:
"require": {
"laravel/framework": "4.1.*", // version could be 4.2.*
"maxhoffmann/parsedown-laravel": "dev-master"
},
The Carbon package is already avaiable with Laravel by default. Also in app/config/app.php add another entry in providers array like this (Check details here):
'providers' => array(
// other entries...
'MaxHoffmann\Parsedown\ParsedownServiceProvider'
),
Also add an entry in aliases array like this:
'aliases' => array(
// other entries...
'Markdown' => 'MaxHoffmann\Parsedown\ParsedownFacade',
),
You said:
or additional folders in the root directory so I don't have to
re-create them each time.
It doesn't make any sense, sorry!.
If I'm understanding you correctly, you can load custom libraries and have them autoloaded via composers "autoload" section. How you actually load the code into you project is up to you. git submodules is a good option. I'm not familiar with the Laravel directory structure so replace the paths to something that fits:
{
"require": {
// requires go here
},
"require-dev": {
// require dev go here
},
"config": {
"bin-dir": "bin/"
},
"autoload": {
"psr-0" : {
"Carbon": "src/lib/Carbon/src",
"Carbon\\Test": "src/lib/Carbon/tests"
}
}
}
Probably best thing to do is install default Laravel, configure as you wish then save your default template on github... that way you can just do git clone url_to_your_template_repository?

Mediawiki extensions, will not read my i18n file

As far as i'm aware, the only steps required in order to create a internationalized extension is to create a i18n file like the following:
//SemanticHighcharts.i18n.php
$messages = array();
$messages['en'] = array(
'semantichighcharts-desc' => 'A SMW result format displaying data with the help of highcharts
);
and then reference this file with the global variable wgExtensionMessageFiles
//SemanticHighcharts.php
global $wgExtensionMessagesFiles, $wgExtensionCredits;
$wgExtensionCredits['semantic'][] = array(
'path' => __FILE__,
'name' => 'SemanticHighcharts',
'version' => '0.0.1',
'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticHighcharts',
'descriptionmsg' => 'semantichighcharts-desc'
);
//i18n
$wgExtensionMessagesFiles['SemanticHighcharts'] = dirname(__FILE__) . '/SemanticHighcharts.i18n.php';
This should cause the descriptionmsg in wgExtensionCredits to be internationalized when displayed on Special:Version.
However this is not the case... In fact, no message key from the i18n file is being read!
How can i debug this issue? I've tried to debug callstack when doing a wfMessage() call without any great success.
Any help is appreciated. I'm running the latest version of mediawiki from git. And all extensions have been installed with composer.
//composer.json
{
"require": {
"php": ">=5.3.2",
"mediawiki/side-bar-menu": "dev-master",
"mediawiki/semantic-highcharts": "dev-master",
"mediawiki/semantic-result-formats": "dev-master"
},
"suggest": {
"ext-fileinfo": "*",
"ext-mbstring": "*",
"ext-wikidiff2": "*",
"ext-apc": "*"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/netbrain/SemanticHighcharts"
}
]
}
Typical, after struggling with this issue for quite some time. Right after posting this question I tried to remove all other extensions from composer.json, and did a composer update. Which magically fixed my issue.
I'm suspecting that there might be a conflicting extension or maybe it was just something wrong with the composer autoloading mechanism.
Ill try to look into it further.
It seems that composer was the culprit, after re-adding the extensions previously removed, it still worked. So i can only guess that there is some quirk in composers dependency management.

Categories