tymon jwt-auth laravel 5.4 error - jwt

I am getting this error after composer update....
I am using laravel version 5.4.*
Call to undefined method Illuminate\Foundation\Application::share()
My providers array
`'providers' => [App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
'Tymon\JWTAuth\Providers\JWTAuthServiceProvider'
],`
My alias array
'aliases' => ['View' => Illuminate\Support\Facades\View::class,
'JWTAuth' => 'Tymon\JWTAuth\Facades\JWTAuth',
'JWTFactory' => 'Tymon\JWTAuth\Facades\JWTFactory'
],
My composer.json
,
"tymon/jwt-auth": "0.5.*"
The error is
C:\wamp\www\myproject\app>php artisan vendor:publish --provider="Tymon\JW
TAuth\Providers\JWTAuthServiceProvider"
PHP Fatal error: Call to undefined method Illuminate\Foundation\Application::sh
are() in C:\wamp\www\myproject\app\vendor\tymon\jwt-auth\src\Providers\JW
TAuthServiceProvider.php on line 122

Use dev-master branch. Edit yout composer json file.
"require": {
...
"tymon/jwt-auth": "dev-master"
...
},
and composer update

When you want to add a provider in app.php the code is like this:
ProviderPath/ProviderName::class,
Change this line:
'providers' => [App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
'Tymon\JWTAuth\Providers\JWTAuthServiceProvider'//this one
],
to
'providers' => [App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class //this one
],

Related

Class 'Modules\Media' not found in eval()'d code on line 1 in Laravel after installing laravel-modules by nWidart

I'm using nWidart's laravel-modules for a project. The idea is great but I don't like having the modules directory starting with a capital letter (Modules).
I decided to change the directory name in the configuration file:
/config/modules.php
I kept the namespace as Modules, but I changed path:
return [
'namespace' => 'Modules',
'paths' => [
'modules' => base_path('modules'), // Used to be ('Modules')
]
];
I added this to the composer.json file:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Modules\\": "modules/"
}
},
Now, I created a Module called Media:
php artisan module:make Media
And also created a model Media:
php artisan module:make-model Media media
My model goes like this:
<?php
namespace Modules\Media\Entities;
use Illuminate\Database\Eloquent\Model;
class Media extends Model{
//
public function categories(){
return $this->belongsToMany( Category::class, 'category_media' );
}
}
Everything works fine, but when I go to tinker
php artisan tinker
And I try to load an Object (which exists) from the database:
$file = \Modules\Media\Entities::find( 1 );
or
$file = Modules\Media\Entities::find( 1 );
or
$file = modules\Media\Entities::find( 1 );
or
$file = \modules\Media\Entities::find( 1 );
I get this error:
PHP Fatal error: Class 'Modules\Media\Entities' not found in eval()'d code on line 1
Any ideas on what might be causing the problem? was it the changeof the directory name? Am I missing something in the composer.json configuration? I have no idea.
After reading my own code, I figured out that I was not referencing the Class, but only the namespace. The correct way to call the Media class was:
$file = \Modules\Media\Entities\Media::find( 1 );
(Notice that this time I end with \Media)
And of course, the result is the expected:
=> Modules\Media\Entities\Media {#857
id: 1,
filename: "my_file.jpg",
properties: "[]",
mime: "image\jpg",
extension: "jpg",
created_at: "2017-05-21 04:37:28",
updated_at: "2017-05-21 04:37:28",
published: 0,
published_at: "2017-05-20 23:37:28",
}

Puppet PostgresQL management

I am trying to provision an EC2 instance using puppet. In the process I have downloaded the puppetlabs-postgresql module from puppetlabs. Since I'm fairly new to puppet, i do not want to manage my database by creating classes in my site.pp file located in /etc/puppet/manifests/site.pp. Rather I want to have a module call database in /etc/puppet/modules/database.
What I have done so far is create an init.pp file in /etc/puppet/modules/database. Below is the content of my init.pp file :
class database {
# resources
postgresql::globals{'globals':
version => '9.3',
manage_package_repo => true,
encoding => 'UTF8',
locale => 'it_IT.utf8',
}
postgresql::server{'server':
ensure => 'present',
listen_addresses => '*',
manage_firewall => true,
}
postgresql::server::contrib{'contrib':
package_ensure => 'present',
}
}
And then in my /etc/puppet/manifests/site.pp file i have included the database class as below :
node default {
include localusers
include database
}
However i keep getting an error :
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type postgresql::globals at /etc/puppet.manifests/init.pp:12
Please what is the correct way to make use of the postgresql classes and resources in my own module and create a database in the module as well ?
You're on the right track, but there are a few issues with how you're using the postgresql module. The reason you're getting the Invalid resource type error is that you're trying to use postgresql::globals as a defined type when it's actually a class. You have the same issue with the other two classes you're using. Try this...
class database {
# set global defaults before creating server
class { 'postgresql::globals':
version => '9.3',
manage_package_repo => true,
encoding => 'UTF8',
locale => 'it_IT.utf8',
}->
class { 'postgresql::server':
listen_addresses => '*',
manage_firewall => true,
}
# install the postgresql contrib package
class { 'postgresql::server::contrib':
package_ensure => 'present',
}
# create database with user and default permissions
postgresql::server::db { 'my_awesome_db':
user => 'my_db_user',
password => 'puppetRocks',
}
}
In the reference section of the module documentation, there's a breakdown of the classes and resources (a.k.a. defined types). The postgresql::server::db type that I used is the simplest way to create a database, user, and permissions all at once. There are separate types available for each of those to provide more fine-grained control.

Symfony CMF Media Bundle - Could not load type "cmf_media_image"

I want to use the CMF Media Bundle for image uploads. The Bundle was installed successfully.
routing.xml
cmf_media_file:
resource: "#CmfMediaBundle/Resources/config/routing/file.xml"
cmf_media_image:
resource: "#CmfMediaBundle/Resources/config/routing/image.xml"
AppKernel.php
$bundles = array(
...
new Symfony\Cmf\Bundle\MediaBundle\CmfMediaBundle(),
);
Now I want to add the following code to my form:
$builder
-> add('image', 'cmf_media_image', array('required' => false))
;
But I get an error message:
Could not load type "cmf_media_image"
What did i miss?
Maybe you should declare the template like this (in config.yml) :
twig:
form:
resources:
- 'CmfMediaBundle:Form:fields.html.twig'
see http://symfony.com/doc/current/cmf/bundles/media/form_types.html for more info

Puppet and Postgres annoying warning: Passing "version" to postgresql::server is deprecated

I'm using the puppet-postgresql module to manage PostgreSQL. That part of the manifest looks like this:
class { 'postgresql::server':
postgres_password => 'postgres',
}
postgresql::server::db { $db_name:
user => $db_user,
password => postgresql_password($db_user, $db_password),
}
Works fine but I get the annoying warning:
Warning: Scope(Class[Postgresql::Server]): Passing "version" to postgresql::server is deprecated; please use postgresql::globals instead.
EDIT:
I even added the version to the globals, but I'm still getting the warning:
class { 'postgresql::globals':
version => '9.3',
}->
class { 'postgresql::server':
postgres_password => 'postgres',
}
postgresql::server::db { $db_name:
user => $db_user,
password => postgresql_password($db_user, $db_password),
}
But I'm not passing any 'version' to postgresql::server. What I'm doing wrong here?
Docs https://forge.puppetlabs.com/puppetlabs/postgresql didn't helped me in this case...
It's a bug in the puppetlabs-postgresql module in the 3.4.x series. It's since been fixed in PR 471 which will be released in the next major version (4.0.0 by the looks of it).
If you don't specify the version, a default version is selected by the module in the file manifests/globals.pp. So you can either edit this file to specify a newer version for your OS or pass the version in parameter when calling postgresql::server

Overwrite if if it exists or create if it does not

I am trying to rewrite a file using puppet with the following function.
If the file exists I still want the file to be rewrite from the source. Will this be achieved with the following method?
define setup_sysctl_conf( $dependence=File[$dummy_dependence_file] )
{
file { $name:
path => '/etc/sysctl.conf',
ensure => present,
mode => 0777,
source => '/vagrant/files/sysctl.conf',
require => $dependence,
}
}
The file: /etc/sysctl.conf will already be present on your host (created by the initscripts package).
I would recommend to modify existing files with puppet using augeas instead of replacing them.
Example (changes net.ipv4.ip_forward to 1):
class sysctl_augeas_example {
augeas{"Set net.ipv4.ip_forward to 1":
context => "/files",
changes => [
"set etc/sysctl.conf/net.ipv4.ip_forward 1",
]
}
}
include sysctl_augeas_example
Save this example as test.pp and run it with puppet apply test.pp