mercredi 28 février 2018

What todo when composer update and composer install give error ?

I run composer install I got this error, telling me to use composer update

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for doctrine/inflector v1.3.0 -> satisfiable by doctrine/inflector[v1.3.0].
    - doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.25) does not satisfy that requirement.
  Problem 2
    - Installation request for symfony/css-selector v4.0.3 -> satisfiable by symfony/css-selector[v4.0.3].
    - symfony/css-selector v4.0.3 requires php ^7.1.3 -> your PHP version (7.0.25) does not satisfy that requirement.
  Problem 3
    - Installation request for symfony/event-dispatcher v4.0.3 -> satisfiable by symfony/event-dispatcher[v4.0.3].
    - symfony/event-dispatcher v4.0.3 requires php ^7.1.3 -> your PHP version (7.0.25) does not satisfy that requirement.
  Problem 4
    - Installation request for doctrine/instantiator 1.1.0 -> satisfiable by doctrine/instantiator[1.1.0].
    - doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (7.0.25) does not satisfy that requirement.
  Problem 5
    - doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.25) does not satisfy that requirement.
    - laravel/framework v5.5.32 requires doctrine/inflector ~1.1 -> satisfiable by doctrine/inflector[v1.3.0].
    - Installation request for laravel/framework v5.5.32 -> satisfiable by laravel/framework[v5.5.32].

I run composer update, I got this

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - doctrine/dbal v2.6.3 requires php ^7.1 -> your PHP version (7.0.25) does not satisfy that requirement.
    - doctrine/dbal v2.6.2 requires php ^7.1 -> your PHP version (7.0.25) does not satisfy that requirement.
    - doctrine/dbal v2.6.1 requires php ^7.1 -> your PHP version (7.0.25) does not satisfy that requirement.
    - doctrine/dbal v2.6.0 requires php ^7.1 -> your PHP version (7.0.25) does not satisfy that requirement.
    - Installation request for doctrine/dbal ^2.6 -> satisfiable by doctrine/dbal[v2.6.0, v2.6.1, v2.6.2, v2.6.3].

Now what should I do ?

This is what I have in composer.json

cat composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "anouar/paypalpayment": ">=3.0",
        "doctrine/dbal": "^2.6",
        "fideloper/proxy": "~3.3",
        "guzzlehttp/guzzle": "^6.3",
        "intervention/image": "^2.4",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
        "spatie/laravel-newsletter": "^4.1",
        "srmklive/paypal": "~1.0"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "~1.0",
        "phpunit/phpunit": "~6.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files": ["app/Http/Helper.php"]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
} 



via Chebli Mohamed

How to autofill Edit form with old Information from two different tables?

I have this form "Edit tache". Editing one "tache" affects two tables user and technicien, when i choose to edit tache the edit form is autofilled with information from the technicien table but the fields related to the table user are not autofilled. How could i autofill the form with information from the two tables? Thank you.

enter image description here

controller

public function edit($id)
{
    $technicien=technicien::find($id);
    $user = user::orderBy('id', 'asc')->get();
    return view('technicien.edit',['moyenne_avis'=>$technicien],['actif'=>$technicien],['user_id'=>$technicien])->with('users', $user );
}

public function update(Request $request, $id)
{
    // do some request validation
    $technicien=technicien::find($id);
    $technicien->update($request->all());
    return redirect('technicien');
}

View

@extends('Layouts/app')
@extends('Layouts.master')
@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-10">
            <h1>Modifier Tache</h1>
        <form action="" method="post">
        
        


            <div class="form-group">
                <label for="">Nom</label>
                <input id="nom" type="text" class="form-control" name="nom" value="" required autofocus>
            </div>
            <div class="form-group">
                <label for="">Prenom</label>
                <input id="nom" type="text" class="form-control" name="nom" value="" required autofocus>
            </div>

            <div class="form-group">
                <label for="">moyenne Avis</label>
                <input type="text"  name ="moyenne_avis" class="form-control"value ="" >
            </div>
            <div class="form-group">
                <label for="">Etat Technicien</label>
                <input type="text"  name ="actif" class="form-control"value ="" >
            </div>



            <div class="form-group">

                <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
            </div>
        </form>
    </div>
</div>
@endsection

route

Route::get('/technicien/{id}/edit', 'TechnicienController@edit');
Route::put('/technicien/{id}', 'TechnicienController@update')-
>name('technicien.update');



via Chebli Mohamed

How to autofill Edit form with old Information of a user?

i have this form "Modifier Technicien" with which I will modify the information of a technician, the modifications will affect two tables of my database table user and table technician. I want my form to be autofilled with the information of the technician I chose to modify. Thank you

enter image description here

edit.blade.php

@extends('Layouts/app')
@extends('Layouts.master')
@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-10">
            <h1>Modifier Technicien</h1>
        <form action="" method="post">
        
        



          <div class="form-group">
                <label for="">Nom</label>
                <input id="nom" type="text" class="form-control" name="nom" value="" required autofocus>

                            @if ($errors->has('nom'))
                                <span class="help-block">
                                    <strong></strong>
                                </span>
                            @endif
            </div>
            <div class="form-group">
                <label for="">Prenom</label>
                <input id="prenom" type="text" class="form-control" name="prenom" value="" required autofocus>

                            @if ($errors->has('prenom'))
                                <span class="help-block">
                                    <strong></strong>
                                </span>
                            @endif
            </div>
            <div class="form-group">
                <label for="">Telephone</label>
                <input id="tel" type="text" class="form-control" name="tel" value="" required autofocus>

                            @if ($errors->has('tel'))
                                <span class="help-block">
                                    <strong></strong>
                                </span>
                            @endif
            </div>
            <div class="form-group">
                <label for="">Mobile</label>
                <input id="mobil" type="text" class="form-control" name="mobil" value="" required autofocus>

                            @if ($errors->has('mobile'))
                                <span class="help-block">
                                    <strong></strong>
                                </span>
                            @endif
            </div>
            <div class="form-group">
                <label for="">Role</label>
                <input id="role" type="text" class="form-control" name="role" value="" required autofocus>

                            @if ($errors->has('role'))
                                <span class="help-block">
                                    <strong></strong>
                                </span>
                            @endif
            </div>



            <div class="form-group">
                <label for="">Moyenne Avis</label>
                <input type="text"  name ="moyenne_avis" class="form-control"value="">
            </div>
            <div class="form-group">
                <div class="form-group">
                <label for="">Etat</label>
                <input type="text"  name ="actif" class="form-control"value="">
            </div>




            <div class="form-group">

                <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
            </div>
        </form>
    </div>
</div>
@endsection

controller

public function edit($id)
{
    $technicien=technicien::find($id);
    $users = user::orderBy('id', 'asc')->get();
    return view('technicien.edit',['moyenne_avis'=>$technicien],['actif'=>$technicien],['user_id'=>$technicien])->with('user', $users);
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $id)
{
     technicien::where('id', $id)->update($request->all());
     return redirect('technicien/edit');
}

route.php

Route::get('/technicien/{id}/edit', 'TechnicienController@edit');
Route::put('/technicien/{id}', 'TechnicienController@update')-
>name('technicien.update');



via Chebli Mohamed

Multiple jobs are processing with one worker

I have an app built on laravel 5.1 which is using RabbitMQ for job processing. The worker command is as follows:

php artisan queue:work --queue=[queue-name] --daemon --tries=5

The issue which I am experiencing is that multiple jobs are getting processed at the same time even though I have only one worker for the queue. How and why is this happening? I have a table which tracks the status of the jobs and as per the table, the number of parallel processing jobs sometimes increase to 8 or 9. With one worker, this count is strange.

Note:

  • My application has 3500-4000 jobs for processing daily
  • The jobs are time consuming so dont know if this has something to do with the process timeout


via Chebli Mohamed

mardi 27 février 2018

Instagram Integration on Laravel 5

I kept getting this issue after installing this package below

https://github.com/vinkla/instagram

into my Laravel 5.1 project.

2018-02-27 at 1 55 36 pm

I followed everything in the instruction.

I am on Mac OS X, PHP 7.1, Laravel 5.1

Did I forget something?

How would one go about and debug this further ?


I'm open to any suggestions at this moment.

Any hints/suggestions / helps on this be will be much appreciated!



via Chebli Mohamed

How to make a dropdown list suggest only options in relation with a selected value?

In my form below i have two dropdown lists the first one to choose "metier" and a second one to choose "tache" when i choose a "metier" i want that the second dropdown list "tache" suggest only options in relation with the already selected "Metier". Could anyone help me with this please.

enter image description here

create.blade.php

@extends('Layouts/app')
@extends('Layouts.master')
@section('content')
@if(count($errors))
<link rel="stylesheet" 
href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script    src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">

 <div class="alert alert-danger" role="alert">
 <ul>
    @foreach($errors ->all() as $message)
     <li></li>
        @endforeach
 </ul>
</div>
@endif
<div class="container">
    <div class="row">
        <div class="col-md-10">
            <h1>Tarification tache</h1>
        <form action=" " method="post">
         

            <div class="form-group">
                <label for="technicien">Technicien</label>
                <select name="technicien_id" id="technicien" class="form-control" >

                        @foreach($techniciens as $techniciens)
                         <option value="">
                            
                         </option>
                        @endforeach
                </select>
            </div>
////////////
            
            <div class="form-group">
                <label for="metier">Libelle metier</label>
                <select name="metier" id="metier" class="form-control">

                        @foreach($metiers as $metier)
                         <option value="">
                            
                         </option>
                        @endforeach
                </select>
            </div>

            <div class="form-group">
                <label for="Tache">Libelle Tache</label>
                <select name="tache" id="Tache" class="form-control">

                        @foreach($taches as $tache)
                         <option value="">
                            
                         </option>
                        @endforeach
                </select>
            </div>
            

//////////////
            <div class="form-group">
                <label for="">Tarif</label>
                <input type="text"  name ="Tarif" class="form-control"value="">
            </div>
            <div class="form-group">
                <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
            </div>
        </form>
    </div>
</div>


<script>
    $('#metier').on('change',function(e){
        console.long(e);
        var met_id = e.target.value;

        $.get('/ajax-tac?met_id=' + met_id, function(data){
            $('#tache').empty();
            $.each(data,function(index, tacObj){
                $('#tache').append('<option value="'+tacObj.id+'">'+catObj.libelle_tache+'</option>');
            });

        });

    });
</script>

@endsection

route.php

Route::get('/tarification', 'TarificationController@index');
Route::get('/tarification/create', 'TarificationController@create');
Route::post('/tarification', 'TarificationController@store');
Route::get('/tarification/{id}/edit', 'TarificationController@edit');
Route::put('/tarification/{id}', 'TarificationController@update');
Route::delete('/tarification/{id}', 'TarificationController@destroy');

Route::get('/ajax-metier',function(){
        $met_id = Input::get('met_id');
        $taches = tache::where('metier_id','=', $met_id)->get();
        return Response::json($metiers);
});

controller

public function create()
{
    $techniciens = technicien::orderBy('id','desc')->get();
    $taches = Tache::orderBy('libelle_tache', 'asc')->get();
    $metiers = Metier::all();
    return view('tarification.create')->with('taches', $taches)->with('techniciens', $techniciens)->with('metiers', $metiers);
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    $tarification = new tarificationtache();

    $tarification ->tache_id = $request->input('tache_id');
    $tarification ->Tarif =$request->input('Tarif');
    $tarification->save();
    $tarification->techniciens()->attach($request->technicien_id);
    return redirect('home');
}



via Chebli Mohamed

Timeout value in case of queue:work

I have an app built on laravel 5.1 which is using RabbitMQ for job processing. The worker command is as follows:

php artisan queue:work --queue=[queue-name] --daemon --tries=5

What is the default timeout value in case of queue:work?

Also, if timeout is set via "set_time_limit" within a job and queue:work has its own timeout lets say 60 seconds, how the job processing is affected? What are the impacts on this conflicting timeouts?



via Chebli Mohamed