CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other

09 April, 2021

Php interview questions for 5 years experience

 Programing Coderfunda     April 09, 2021     Interview Question, php, PHP-Interview-Questions     No comments   

 Top 50 PHP Interview Questions You Must Prepare in 2021

PHP is a recursive acronym for PHP Hypertext Preprocessor. It is a widely used open-source programming language especially suited for creating dynamic websites and mobile API’s. So, if you are planning to start your career in PHP and you wish to know the skills related to it, now is the right time to dive in. These PHP Interview Questions and Answers are collected after consulting with PHP Certification Training experts.

The PHP Interview Questions are divided into 2 sections:

  • Basic Level PHP Interview Questions
  • Advanced Level PHP Interview Questions

Let’s begin with the first section of PHP interview questions.

Basic Level PHP Interview Questions

Q1. What are the common uses of PHP ?

Uses of PHP
  • It performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
  • It can handle forms, i.e. gather data from files, save data to a file, through email you can send data, return data to the user.
  • You can add, delete, modify elements within your database with the help of PHP.
  • Access cookies variables and set cookies.
  • Using PHP, you can restrict users to access some pages of your website and also encrypt data.

Q2. What is PEAR in PHP?

PEAR is a framework and repository for reusable PHP components. PEAR stands for PHP Extension and Application Repository. It contains all types of PHP code snippets and libraries. It also provides a command line interface to install “packages” automatically.


Q3. What is the difference between static and dynamic websites?

Static WebsitesDynamic Websites
In static websites, content can’t be changed after running the script. You cannot change anything in the site as it is predefined.In dynamic websites, content of script can be changed at the run time. Its content is regenerated every time a user visits or reloads.

Q4. How to execute a PHP script from the command line?

To execute a PHP script, use the PHP Command Line Interface (CLI) and specify the file name of the script in the following way:

1
php script.php

Q5. Is PHP a case sensitive language?

PHP is partially case sensitive. The variable names are case-sensitive but function names are not. If you define the function name in lowercase and call them in uppercase, it will still work. User-defined functions are not case sensitive but the rest of the language is case-sensitive.

Q6. What is the meaning of ‘escaping to PHP’?

The PHP parsing engine needs a way to differentiate PHP code from other elements in the page. The mechanism for doing so is known as ‘escaping to PHP’. Escaping a string means to reduce ambiguity in quotes used in that string.

Q7. What are the characteristics of PHP variables?

Some of the important characteristics of PHP variables include:

  • All variables in PHP are denoted with a leading dollar sign ($).
  • The value of a variable is the value of its most recent assignment.
  • Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right.
  • Variables can, but do not need, to be declared before assignment.
  • Variables in PHP do not have intrinsic types – a variable does not know in advance whether it will be used to store a number or a string of characters.
  • Variables used before they are assigned have default values.

Q8. What are the different types of PHP variables?

There are 8 data types in PHP which are used to construct the variables:

  1. Integers − are whole numbers, without a decimal point, like 4195.
  2. Doubles − are floating-point numbers, like 3.14159 or 49.1.
  3. Booleans − have only two possible values either true or false.
  4. NULL − is a special type that only has one value: NULL.
  5. Strings − are sequences of characters, like ‘PHP supports string operations.’
  6. Arrays − are named and indexed collections of other values.
  7. Objects − are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class.
  8. Resources − are special variables that hold references to resources external to PHP.

Q9. What are the rules for naming a PHP variable?

The following rules are needed to be followed while  naming a PHP variable:

  • Variable names must begin with a letter or underscore character.
  • A variable name can consist of numbers, letters, underscores but you cannot use characters like + , – , % , ( , ) . & , etc.

Q10. What are the rules to determine the “truth” of any value which is not already of the Boolean type?

The rules to determine the “truth” of any value which is not already of the Boolean type are:

  • If the value is a number, it is false if exactly equal to zero and true otherwise.
  • If the value is a string, it is false if the string is empty (has zero characters) or is the string “0”, and is true otherwise.
  • Values of type NULL are always false.
  • If the value is an array, it is false if it contains no other values, and it is true otherwise. For an object, containing a value means having a member variable that has been assigned a value.
  • Valid resources are true (although some functions that return resources when they are successful will return FALSE when unsuccessful).
  • Don’t use double as Booleans.

Q11. What is NULL?

NULL is a special data type which can have only one value. A variable of data type NULL is a variable that has no value assigned to it. It can be assigned as follows:

1
$var = NULL;

The special constant NULL is capitalized by convention but actually it is case insensitive. So,you can also write it as :

1
$var = null;

A variable that has been assigned the NULL value, consists of the following properties:

  • It evaluates to FALSE in a Boolean context.
  • It returns FALSE when tested with IsSet() function.

Q12. How do you define a constant in PHP?

To define a constant you have to use define() function and to retrieve the value of a constant, you have to simply specifying its name.If you have defined a constant, it can never be changed or undefined. There is no need to have a constant with a $. A valid constant name starts with a letter or underscore.

Q13. What is the purpose of constant() function?

The constant() function will return the value of the constant. This is useful when you want to retrieve value of a constant, but you do not know its name, i.e., it is stored in a variable or returned by a function. For example –

1
<?php define("MINSIZE", 50); echo MINSIZE; echo constant("MINSIZE"); // same thing as the previous line ?>

Q14. What are the differences between PHP constants and variables?

ConstantsVariables
There is no need to write dollar ($) sign before a constantA variable must be written with the dollar ($) sign
Constants can only be defined using the define() functionVariables can be defined by simple assignment
Constants may be defined and accessed anywhere without regard to variable scoping rules.In PHP, functions by default can only create and access variables within its own scope.
Constants cannot  be redefined or undefined.Variables can be redefined for each path individually.

Q15. Name some of the constants  in PHP and their purpose.

  1.  _LINE_ – It represents the current line number of the file.
  2.  _FILE_ – It represents the full path and filename of the file. If used inside an include,the name of the included file is returned.
  3. _FUNCTION_ – It represents the function name.
  4. _CLASS_ – It returns the class name as it was declared.
  5. _METHOD_ – It represents the class method name.

Q16. What is the purpose of break and continue statement?

Break – It terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch.

Continue – It causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

Q17. What are the two most common ways to start and finish a PHP block of code?

The two most common ways to start and finish a PHP block of code are:

1
<?php [ --- PHP code---- ] ?>

 

1
<? [--- PHP code ---] ?>

Q18. What is the difference between PHP4 and PHP5?

PHP4PHP5
  • Constructor have same name as the Class name.
  • Constructors are named as _construct and Destructors as _destruct().
  • Everything is passed by value.
  • All objects are passed by references.
  • PHP4  does not declare a class as abstract
  • PHP5 allows to declare a class as abstract
  • It doesn’t have static methods and properties in a class
  • It allows to have static Methods and Properties in a class

Q19.  What is the meaning of a final class and a final method?

The final keyword in a method declaration indicates that the method cannot be overridden by subclasses. A class that is declared final cannot be subclassed. This is particularly useful when we are creating an immutable class like the String class.Properties cannot be declared final, only classes and methods may be declared as final.

Q20.  How can you compare objects in PHP?

We use the operator ‘==’ to test if two objects are instanced from the same class and have same attributes and equal values. We can also test if two objects are referring to the same instance of the same class by the use of the identity operator ‘===’.

Q21. How can PHP and Javascript interact?

PHP and Javascript cannot directly interact since PHP is a server side language and Javascript is a client-side language. However, we can exchange variables since PHP can generate Javascript code to be executed by the browser and it is possible to pass specific variables back to PHP via the URL.


Q22. How can PHP and HTML interact?

It is possible to generate HTML through PHP scripts, and it is possible to pass pieces of information from HTML to PHP. PHP is a server side language and HTML is a client side language so PHP executes on server side and gets its results as strings, arrays, objects and then we use them to display its values in HTML.

Q23. Name some of the popular frameworks in PHP.

Some of the popular frameworks in PHP are:

  • CakePHP
  • CodeIgniter
  • Yii 2
  • Symfony
  • Zend Framework

Q24. What are the data types in PHP?

PHP support 9 primitive data types:

Scalar TypesCompound TypesSpecial Types
  • Integer
  • Boolean
  • Float
  • String
  • Array
  • Object
  • Callable
  • Resource
  • Null

Q25. What are constructor and destructor in PHP?

PHP constructor and  destructor are special type functions which are automatically called when a PHP class object is created and destroyed. The constructor is the most useful of the two because it allows you to send parameters along when creating a new object, which can then be used to initialize variables on the object.

Here is an example of constructor and destructor in PHP:

1
2
3
4
5
6
7
8
9
10
11
12
<?php class Foo { private $name; private $link; public function __construct($name) { $this->;name = $name;
}
 
public function setLink(Foo $link){
$this->;link = $link;
}
 
public function __destruct() {
echo 'Destroying: ', $this->name, PHP_EOL;
}
}
?>

Q26. What are include() and require() functions?

The Include() function is used to put data of one PHP file into another PHP file. If errors occur then the include() function produces a warning but does not stop the execution of the script and it will continue to execute.

The Require() function is also used to put data of one PHP file to another PHP file. If there are any errors then the require() function produces a warning and a fatal error and stops the execution of the script.

Q27. What is the main difference between require() and require_once()?

The require() includes and evaluates a specific file, while require_once() does that only if it has not been included before.  The require_once() statement can be used to include a php file in another one, when you may need to include the called file more than once. So, require_once() is recommended to use when you want to include a file where you have a lot of functions. 

Q28. What are different types of errors available in Php ?


The different types of error in PHP are:

  • E_ERROR– A fatal error that causes script termination.
  • E_WARNING– Run-time warning that does not cause script termination.
  • E_PARSE– Compile time parse error.
  • E_NOTICE– Run time notice caused due to error in code.
  • E_CORE_ERROR– Fatal errors that occur during PHP initial startup.
  • E_CORE_WARNING– Warnings that occur during PHP initial startup.
  • E_COMPILE_ERROR– Fatal compile-time errors indication problem with script.
  • E_USER_ERROR– User-generated error message.
  • E_USER_WARNING– User-generated warning message.
  • E_USER_NOTICE- User-generated notice message.
  • E_STRICT– Run-time notices.
  • E_RECOVERABLE_ERROR– Catchable fatal error indicating a dangerous error
  • E_ALL– Catches all errors and warnings.

Q29. Explain the syntax for ‘foreach’ loop with example.

The foreach statement is used to loop through arrays. For each pass the value of the current array element is assigned to $value and the array pointer is moved by one and in the next pass next element will be processed.

Syntax-

foreach (array as value)
{
code to be executed;
}

Example-

1
2
3
4
5
6
7
8
<?php
$colors = array("blue", "white", "black");
 
foreach ($colors as $value) {
echo "$value
";
}
?>

Q30. What are the different types of Array in PHP?

There are 3 types of Arrays in PHP:

  1. Indexed Array – An array with a numeric index is known as the indexed array. Values are stored and accessed in linear fashion.
  2. Associative Array – An array with strings as index is known as the associative array. This stores element values in association with key values rather than in a strict linear index order.
  3. Multidimensional Array – An array containing one or more arrays is known as multidimensional array. The values are accessed using multiple indices.

Q31. What is the difference between single quoted string and double quoted string?

Singly quoted strings are treated almost literally, whereas doubly quoted strings replace variables with their values as well as specially interpreting certain character sequences. For example –

1
2
3
4
5
6
7
8
9
<?php
$variable = "name";
$statement = 'My $variable will not print!n';
print($statement);
print "
;"
$statement = "My $variable will print!n"
print($statement);
?>

It will give the following output–

My $variable will not print!

My name will print

Q32. How to concatenate two strings in PHP?

To concatenate two string variables together, we use the dot (.) operator.

1
<?php $string1="Hello edureka"; $string2="123"; echo $string1 . " " . $string2; ?>

This will produce following result −

Hello edureka 123

Q33. How is it possible to set an infinite execution time for PHP script?

The set_time_limit(0) added at the beginning of a script sets to infinite the time of execution to not have the PHP error ‘maximum execution time exceeded.’ It is also possible to specify this in the php.ini file.

Q34. What is the difference between “echo” and “print” in PHP?

  • PHP echo output one or more string. It is a language construct not a function. So use of parentheses is not required. But if you want to pass more than one parameter to echo, use of parentheses is required. Whereas, PHP print output a string. It is a language construct not a function. So use of parentheses is not required with the argument list. Unlike echo, it always returns 1.
  • Echo can output one or more string but print can only output one string and always returns 1.
  • Echo is faster than print because it does not return any value.

Q35. Name some of the functions in PHP.

Some of the functions in PHP include:

  • ereg() – The ereg() function searches a string specified by string for a string specified by pattern, returning true if the pattern is found, and false otherwise.
  • ereg() – The ereg() function searches a string specified by string for a string specified by pattern, returning true if the pattern is found, and false otherwise.
  • split() – The split() function will divide a string into various elements, the boundaries of each element based on the occurrence of pattern in string.
  • preg_match() – The preg_match() function searches string for pattern, returning true if pattern exists, and false otherwise.
  • preg_split() – The preg_split() function operates exactly like split(), except that regular expressions are accepted as input parameters for pattern.

These were some of the most commonly asked basic level PHP interview questions. Let’s move on to the next section of advanced level PHP interview questions.

Advanced level PHP Interview Questions

Q36. What is the main difference between asp net and PHP?

PHP is a programming language whereas ASP.NET is a programming framework. Websites developed by ASP.NET may use C#, but also other languages such as J#. ASP.NET is compiled whereas PHP is interpreted. ASP.NET is designed for windows machines, whereas PHP is platform free and typically runs on Linux servers.

Q37. What is the use of session and cookies in PHP?

A session is a global variable stored on the server. Each session is assigned a unique id which is used to retrieve stored values. Sessions have the capacity to store relatively large data compared to cookies. The session values are automatically deleted when the browser is closed.

Following example shows how to create a cookie in PHP-

1
<?php $cookie_value = "edureka"; setcookie("edureka", $cookie_value, time()+3600, "/your_usename/", "edureka.co", 1, 1); if (isset($_COOKIE['cookie'])) echo $_COOKIE["edureka"]; ?>

Following example shows how to start a session in PHP-

1
<?php session_start(); if( isset( $_SESSION['counter'] ) ) { $_SESSION['counter'] += 1; }else { $_SESSION['counter'] = 1; } $msg = "You have visited this page". $_SESSION['counter']; $msg .= "in this session."; ?>

Q38. What is overloading and overriding in PHP?

Overloading is defining functions that have similar signatures, yet have different parameters. Overriding is only pertinent to derived classes, where the parent class has defined a method and the derived class wishes to override that method. In PHP, you can only overload methods using the magic method __call.

Q40. What is the difference between $message and $$message in PHP?

They are both variables. But $message is a variable with a fixed name. $$message is a variable whose name is stored in $message. For example, if $message contains “var”, $$message is the same as $var.

Q41. How can we create a database using PHP and MySQL?

The basic steps to create MySQL database using PHP are:

  • Establish a connection to MySQL server from your PHP script.
  • If the connection is successful, write a SQL query to create a database and store it in a string variable.
  • Execute the query.

Q42. What is GET and POST method in PHP?

The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character. For example –

1
<a href="http://www.test.com/index.htm?name1=value1&name2=value2">http://www.test.com/index.htm?name1=value1&name2=value2</a>

The POST method transfers information via HTTP headers. The information is encoded as described in case of GET method and put into a header called QUERY_STRING.

Q43. What is the difference between GET and POST method?

GETPOST
  • The GET method is restricted to send upto 1024 characters only.
  • The POST method does not have any restriction on data size to be sent.
  • GET can’t be used to send binary data, like images or word documents, to the server.
  • The POST method can be used to send ASCII as well as binary data.
  • The data sent by GET method can be accessed using QUERY_STRING environment variable.
  • The data sent by POST method goes through HTTP header so security depends on HTTP protocol.
  • The PHP provides $_GET associative array to access all the sent information using GET method.
  • The PHP provides $_POST associative array to access all the sent information using POST method.

Q44. What is the use of callback in PHP?

PHP callback are functions that may be called dynamically by PHP. They are used by native functions such as array_map, usort, preg_replace_callback, etc. A callback function is a function that you create yourself, then pass to another function as an argument. Once it has access to your callback function, the receiving function can then call it whenever it needs to.

Here is a basic example of callback function –

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
 
function thisFuncTakesACallback($callbackFunc)
{
echo "I'm going to call $callbackFunc!
";
$callbackFunc();
}
function thisFuncGetsCalled()
{
echo "I'm a callback function!
";
}
 
thisFuncTakesACallback( 'thisFuncGetsCalled' );
?>

Q45.  What is a lambda function in PHP?

A lambda function is an anonymous PHP function that can be stored in a variable and passed as an argument to other functions or methods. A closure is a lambda function that is aware of its surrounding context. For example –

1
2
$input = array(1, 2, 3, 4, 5);
$output = array_filter($input, function ($v) { return $v > 2; });

function ($v) { return $v > 2; } is the lambda function definition. We can store it in a variable so that it can be reusable.

Q46. What are PHP Magic Methods/Functions?

In PHP all functions starting with __ names are magical functions/methods. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met. PHP provides a number of ‘magic‘ methods that allow you to do some pretty neat tricks in object oriented programming.

Here are list of Magic Functions available in PHP

__destruct()__sleep()
__construct()__wakeup()
__call()__toString()
__get()__invoke()
__set()__set_state()
__isset()__clone()
__unset()__debugInfo()

Q47. How can you encrypt password using PHP?

The crypt () function is used to create one way encryption. It takes one input string and one optional parameter. The function is defined as: crypt (input_string, salt), where input_string consists of the string that has to be encrypted and salt is an optional parameter. PHP uses DES for encryption. The format is as follows:

1
<?php $password = crypt('edureka'); print $password. "is the encrypted version of edureka"; ?>

Q48. How to connect to a URL in PHP?

PHP provides a library called cURL that may already be included in the installation of PHP by default. cURL stands for client URL, and it allows you to connect to a URL and retrieve information from that page such as the HTML content of the page, the HTTP headers and their associated data.

Q49. What is Type hinting in PHP?

Type hinting is used to specify the expected data type of an argument in a function declaration. When you call the function, PHP will check whether or not the arguments are of the specified type. If not, the run-time will raise an error and execution will be halted.

Here is an example of type hinting–

1
2
3
<?php function sendEmail (Email $email) { $email->send();
}
?>

The example shows how to send Email function argument $email Type hinted of Email Class. It means to call this function you must have to pass an email object otherwise an error is generated.

Q50. What is the difference between runtime exception and compile time exception?

An exception that occurs at compile time is called a checked exception. This exception cannot be ignored and must be handled carefully. For example, if you use FileReader class to read data from the file and the file specified in class constructor does not exist, then a FileNotFoundException occurs and you will have to manage that exception. For the purpose, you will have to write the code in a try-catch block and handle the exception. On the other hand, an exception that occurs at runtime is called unchecked-exception.

With this, we have come to the end of PHP interview questions blog. I Hope these PHP Interview Questions will help you in your interviews.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Basic Level PHP Interview Questions

 Programing Coderfunda     April 09, 2021     No comments   

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Advanced Level PHP Interview Questions

 Programing Coderfunda     April 09, 2021     No comments   

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

01 April, 2021

Translate Laravel Languages with Google Sheets

 Programing Coderfunda     April 01, 2021     Laravel, Packages     No comments   

Translate Laravel Languages with Google Sheets

Laravel Translation Sheet is a package by Nassif Bourguig for translating Laravel language files using Google Sheets. What I love about this idea/package, is how easy it makes the process of collaborating on language translations with a standard tool like Google Sheets.

Related: Building a Laravel Translation Package

The way that you interact with Google Sheets is through a series of artisan commands and the Google Sheets API:

# Setup and prep commands
php artisan translation_sheet:setup
php artisan translation_sheet:prepare

# Publish translation to Google Sheets
php artisan translation_sheet:push



Once the translations are ready to go, you can use the pull command to pull the translations from the spreadsheet and write to the language-specific files in your Laravel application:

php artisan translation_sheet:pull

Using the pull command syncs the translations from Google Sheets the configured language translation files. You are free to do a diff on them through version control, test them out, and finally commit them to your application.

Once you receive translations and have pulled them into your application, you can lock the sheet to avoid conflicts:

# Lock the sheet to avoid conflicts
php artisan translation_sheet:lock

You can learn more about Laravel Translation Sheet on GitHub at nikaia/translation-sheet. To learn how to install and use the package, check out the project’s README file.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Process Stamps Logs the Process Used to Update Models

 Programing Coderfunda     April 01, 2021     Laravel, Packages     No comments   

 

Laravel Process Stamps Logs the Process Used to Update Models

Laravel Process Stamps is a package by Tom Schlick which makes it easy to track which process created or updated a model record in your database. The Laravel Process Stamps package makes this easy by adding the following trait to your models:

// User model
class User extends Model
{
use ProcessStampable;

// ...
}

When you create or save a new user in the example above, a new record will exist in the configured table (default table name is process_stamps) with a hash, process name, and type when a record gets created or updated.

You can learn more about this package, get full installation instructions, and view the source code on GitHub at orisintel/laravel-process-stamps.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Google Translate

 Programing Coderfunda     April 01, 2021     Laravel, Packages     No comments   

 

Laravel Google Translate

Laravel Google Translate is a package that provides an artisan console command to translate your localization files with the Google translation API. You can either leverage stichoza/google-translate-php without an API key or configure your Google Translate API key.

The console command php artisan translate:files walks you through some prompts to determine how to proceed with your translations files:

Laravel Google Translate


Future goals of this package include handling vendor translations, a web interface, and adding other translation APIs such as Yandex, Bing, etc.

You can learn more about this package, get full installation instructions, and view the source code on GitHub at tanmuhittin/laravel-google-translate.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Junges Laravel ACL Packages

 Programing Coderfunda     April 01, 2021     Laravel, Packages     No comments   

 

Junges Laravel ACL

Junges Laravel ACL is a package by Mateus Junges that helps you to associate users with permissions and permission groups.

This package stores permissions for users and groups (to which users may belong) in the database with the following core features:

  • Check a user for ACL permissions
  • Sync a user’s permissions
  • Sync a group’s permissions
  • Check permissions in the view layer with @can or provided custom directives

At the heart of this package is the UserTrait:

use Illuminate\Foundation\Auth\User as Authenticatable;
use Junges\ACL\Traits\UsersTrait;

class User extends Authenticatable
{
use UserTrait;

//
}

You can sync user and group permissions with the syncPermissions() method:

// With permission id array:
$user->syncPermissions([1, 2, 4]);

// With permission slugs array:
$user->syncPermissions(['permission-slug-1', 'permission-slug-2']);

// With instance of permission model arrays:
$user->syncPermissions([Permission::find(1), Permission::find(2)]);

// Just as above you can sync group permissions. Here's the id version:
$group->syncPermissions([1, 2, 4]);

Check out the usage documentation for a complete list of methods and package capabilities. You can learn more about this package and check out the source code on GitHub at mateusjunges/laravel-acl.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Money

 Programing Coderfunda     April 01, 2021     Laravel, Packages     No comments   

 

Laravel Money

Laravel Money is a composer package by Ricardo Gobbo de Souza for working with and formatting money in Laravel projects.

Laravel money uses the moneyphp/money PHP package under the hood and gives you a bunch of helpers:

use Cknow\Money\Money;

echo Money::USD(500); // $5.00

This package includes a ton of advanced features for doing money operations, comparisons, aggregations, formatting, and parsing:

// Basic operations
Money::USD(500)->add(Money::USD(500)); // $10.00
Money::USD(500)->subtract(Money::USD(400)); // $1.00

// Aggregation
Money::min(Money::USD(100), Money::USD(200), Money::USD(300)); // Money::USD(100)

// Formatters
Money::USD(500)->format(); // $5.00

// Parsers
Money::parse('$1.00'); // Money::USD(100)

You can also create a custom formatter for your specific use-case:

Money::USD(500)->formatByFormatter(new MyFormatter());

Be sure to check out the advanced usage and included helper functions in the project’s README file. Also, check out the Money PHP documentation for complete details of what this package is capable of doing.

You can learn more about this package and check out the source code on GitHub at cknow/laravel-money.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

MailEclipse: Laravel Mail Editor Package

 Programing Coderfunda     April 01, 2021     Laravel, Packages     No comments   

 

MailEclipse: Laravel Mail Editor Package

MailEclipse is a mailable editor package for your Laravel applications to create and manage mailables using a web UI. You can use this package to develop mailables without using the command line, and edit templates associated with mailables using a WYSIWYG editor, among other features.

You can even edit your markdown mailable templates:

When creating a mailable template, you can pick from existing themes provided by this package:

The best way to get an idea of what this package does is to install it and try it out or check out this five-minute demo from the author:

Note: the video doesn’t provide sound, but does give an excellent overview and demo of MailEclipse features.

At the time of writing this package is a work in progress and under active development. Part of being under active development means that if you’re interested, you’re encouraged to try this package out and provide feedback.

To start using this package, check out the source code and readme at Qoraiche/laravel-mail-editor on GitHub.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Blade Filters Package

 Programing Coderfunda     April 01, 2021     Laravel, Packages     No comments   

 

Laravel Blade Filters Package

Blade Filters is a package by Gergo D. Nagy that adds the concept of filters to your blade templates. If you’re familiar with Django’s templating system or Symfony’s Twig templating language, the concept of a filter looks like this:

{{ 'john' | ucfirst }} // John

Alternatively, you could write the same thing like this in Blade without the concept of filters:

{{ ucfirst('john') }}

Chained usage is where I personally feel filters begin to shine over function calls:

{{ 'john' | ucfirst | substr:0,1 }} // J

{{ substr(ucfirst('john'), 0, 1) }}

More usefully, here’s how you’d use filters with a template variable:

{{ $currentUser->name | ucfirst | substr:0,1 }}

Finally, this package provides filters that leverage built-in Laravel APIs:

{{ 'This is a title' | slug }} // this-is-a-title

{{ 'This is a title' | title }} // This Is A Title

{{ 'foo_bar' | studly }} // FooBar

To learn more about this package—including installation instructions—check out the source code on GitHub at thepinecode/blade-filters. Also, the package author Gergo wrote a detailed article that explains how to build a custom ViewServiceProvider that you should check out!

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Eloquent Cloner Package

 Programing Coderfunda     April 01, 2021     Laravel, Packages     No comments   

Eloquent Cloner Package


Cloner is a trait for Laravel Eloquent models that lets you clone a model, and it’s relationships, including files. Even to another database.

Here’s a basic example of a model using the Cloneable trait:

class Article extends Eloquent
{
use \Bkwld\Cloner\Cloneable;
}

Here’s how you can clone a model instance, even to another database:

$clone = Article::first()->duplicate();

// Cloned to another database by connection name
$clone = Article::first()->duplicateTo('production');

A more advanced example includes defining which relationships cloned along with the model:

class Article extends Eloquent
{
use \Bkwld\Cloner\Cloneable;

protected $cloneable_relations = ['photos', 'authors'];

public function photos() {
return $this->hasMany('Photo');
}

public function authors() {
return $this->belongsToMany('Author');
}
}

Check out the documentation for full details on how you can also define how to clone files attached to a model. You can learn more about this app and check out the source code on GitHub at BKWLD/cloner.


Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Posts Older Posts Home

Meta

Popular Posts

  • Inertia and React or Vue
    Hi just checking your thoughts on whether to learn React or Vue, I want to learn React as it may be better to find work and it has a larger ...
  • Show page numbers as navigation in Laravel pagination
      Answer Sorted by:                                                Highest score (default)                                                  ...
  • Bootstrap - Code
    Bootstrap - Code Bootstrap allows you to display code with two different key ways − The first is the <code> tag. If you are going to ...
  • Laravel Passwordless Login
      Laravel Passwordless login is a package by   Ed Grosvenor   that provides a simple, safe, magic login link generator for Laravel apps: Thi...
  • Laravel check if eloquent just created
      <?php laravel check  if  eloquent just created $item  =  Item :: firstOrCreate ([ 'title'  =>  'Example Item' ]); if...

Categories

  • Ajax (26)
  • Bootstrap (30)
  • DBMS (42)
  • HTML (12)
  • HTML5 (45)
  • JavaScript (10)
  • Jquery (34)
  • Jquery UI (2)
  • JqueryUI (32)
  • Laravel (1017)
  • Laravel Tutorials (23)
  • Laravel-Question (6)
  • Magento (9)
  • Magento 2 (95)
  • MariaDB (1)
  • MySql Tutorial (2)
  • PHP-Interview-Questions (3)
  • Php Question (13)
  • Python (36)
  • RDBMS (13)
  • SQL Tutorial (79)
  • Vue.js Tutorial (69)
  • Wordpress (150)
  • Wordpress Theme (3)
  • codeigniter (108)
  • oops (4)
  • php (853)

Social Media Links

  • Follow on Twitter
  • Like on Facebook
  • Subscribe on Youtube
  • Follow on Instagram

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

  • July (4)
  • September (100)
  • August (50)
  • July (56)
  • June (46)
  • May (59)
  • April (50)
  • March (60)
  • February (42)
  • January (53)
  • December (58)
  • November (61)
  • October (39)
  • September (36)
  • August (36)
  • July (34)
  • June (34)
  • May (36)
  • April (29)
  • March (82)
  • February (1)
  • January (8)
  • December (14)
  • November (41)
  • October (13)
  • September (5)
  • August (48)
  • July (9)
  • June (6)
  • May (119)
  • April (259)
  • March (122)
  • February (368)
  • January (33)
  • October (2)
  • July (11)
  • June (29)
  • May (25)
  • April (168)
  • March (93)
  • February (60)
  • January (28)
  • December (195)
  • November (24)
  • October (40)
  • September (55)
  • August (6)
  • July (48)
  • May (2)
  • January (2)
  • July (6)
  • June (6)
  • February (17)
  • January (69)
  • December (122)
  • November (56)
  • October (92)
  • September (76)
  • August (6)

Loading...

Laravel News

Loading...

Copyright © CoderFunda | Powered by Blogger
Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda