<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Célien Boillat🇨🇭</title>
    <description>The latest articles on DEV Community by Célien Boillat🇨🇭 (@celienboillat).</description>
    <link>https://dev.to/celienboillat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F224624%2Fdceb04ef-79fc-4676-9f43-4299776a9786.png</url>
      <title>DEV Community: Célien Boillat🇨🇭</title>
      <link>https://dev.to/celienboillat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/celienboillat"/>
    <language>en</language>
    <item>
      <title>ELI5 - Primitive data types in programming</title>
      <dc:creator>Célien Boillat🇨🇭</dc:creator>
      <pubDate>Tue, 06 Apr 2021 07:40:38 +0000</pubDate>
      <link>https://dev.to/celienboillat/eli5-primitive-data-types-in-programming-5dkf</link>
      <guid>https://dev.to/celienboillat/eli5-primitive-data-types-in-programming-5dkf</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  New ELI5 series
&lt;/h3&gt;

&lt;p&gt;Welcome to this first post of the new &lt;strong&gt;ELI5&lt;/strong&gt; series where I'm teaching myself various topics centered around coding and development in general and then explaining them to you in the most simple way for you to understand.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Pretender
&lt;/h3&gt;

&lt;p&gt;"Keep you in the dark, you know they all pretend".&lt;/p&gt;

&lt;p&gt;I certainly was one of those people and I was embarrassed by it.&lt;/p&gt;

&lt;p&gt;Primitive data types were the kind of simple programming concepts I did not learn in school and couldn't be bothered to look into until I stumbled over that particular term over and over when learning more advanced stuff like front-end frameworks.&lt;/p&gt;

&lt;p&gt;There is no shame in not knowing everything but you can't keep procrastinating and pretending like you know when you do not.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are primitive data types?
&lt;/h2&gt;

&lt;p&gt;First, primitive data types are not data types that have not been properly civilized which would not make any sense anyway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fundamental building blocks
&lt;/h3&gt;

&lt;p&gt;Primitive data types or primitive types as they are often called, are the basic building blocks of all programming languages. You could see them as simple bricks. A brick in itself is not of much use unless you are a rioter. But by assembling a multitude of those simple bricks, you can build a wall, which is still very basic but already much more useful than a single brick. You could then go on and build multiple walls and connect them together to eventually build a house which we humans have been doing for thousands of years.&lt;/p&gt;

&lt;p&gt;That is exactly what we are doing as developers/programmers/engineers when we write code and manipulate data to get something useful out of it.&lt;/p&gt;

&lt;h3&gt;
  
  
  What characterizes primitive data types
&lt;/h3&gt;

&lt;p&gt;Primitive data types are built-in types provided by a programming language, such as PHP and JavaScript as their basic building blocks as previously explained. They:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are provided by the programming language&lt;/li&gt;
&lt;li&gt;Have built-in support&lt;/li&gt;
&lt;li&gt;Hold simple values like characters and numerics although some objects compositing primitive values can also be considered primitives themselves&lt;/li&gt;
&lt;li&gt;Are the fastest language constructs&lt;/li&gt;
&lt;li&gt;In most languages, they cannot be extended&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Primitive types in PHP
&lt;/h2&gt;

&lt;p&gt;Although PHP is a weakly typed language, it still uses types behind the scenes, even if you're not actively typing your variables.&lt;/p&gt;

&lt;p&gt;Primitive data types in PHP include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strings (&lt;code&gt;string&lt;/code&gt;) like &lt;code&gt;"C"&lt;/code&gt; and &lt;code&gt;"I love PHP"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Booleans (&lt;code&gt;bool&lt;/code&gt;) like &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Integers (&lt;code&gt;int&lt;/code&gt;) like &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;999&lt;/code&gt;, &lt;code&gt;-1&lt;/code&gt; etc...&lt;/li&gt;
&lt;li&gt;Floating-point numbers (&lt;code&gt;float&lt;/code&gt;) like &lt;code&gt;19.95&lt;/code&gt; and &lt;code&gt;10.00&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those first four are in a subdivision called &lt;strong&gt;scalar types&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The next subdivision is called &lt;strong&gt;compound types&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrays (&lt;code&gt;[]&lt;/code&gt;) like &lt;code&gt;["Elon", "Jordan", "Tanya"]&lt;/code&gt; and &lt;code&gt;[1, 2, 3, -1, 999]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Objects (&lt;code&gt;{}&lt;/code&gt;) like &lt;code&gt;{ first_name: "Elon", last_name: "Musk", hobby: "Trolling Twitter" }&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.php.net/manual/en/language.types.callable.php"&gt;Callable&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.php.net/manual/en/language.types.iterable.php"&gt;Iterable&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last two I will not explain as they would require an entire article to do so, but I provided you with a link to the PHP documentation if you're interested.&lt;/p&gt;

&lt;h2&gt;
  
  
  Primitive types in JavaScript
&lt;/h2&gt;

&lt;p&gt;JavaScript is also a weakly typed language like PHP.&lt;/p&gt;

&lt;p&gt;Primitive data types in JavaScript include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strings (&lt;code&gt;String&lt;/code&gt;) like &lt;code&gt;"C"&lt;/code&gt; and &lt;code&gt;"Why isn't this TypeScript?"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Numbers (&lt;code&gt;Number&lt;/code&gt;) like &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;-1&lt;/code&gt;, &lt;code&gt;999&lt;/code&gt; but also &lt;code&gt;19.95&lt;/code&gt; and &lt;code&gt;-10.00&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Booleans (&lt;code&gt;Boolean&lt;/code&gt;) like &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Big Integers (&lt;code&gt;BigInt&lt;/code&gt;) like &lt;code&gt;9007199254740991&lt;/code&gt; and &lt;code&gt;0x1fffffffffffff&lt;/code&gt; which is a special notation&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol"&gt;Symbols&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last one is a bit peculiar, so I provided you a link to the documentation if you're interested in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing word
&lt;/h2&gt;

&lt;p&gt;That's the end of this short article and I hope you could learn something. There is of course much more to learn about primitive data types, of course, depending on the languages you use but that's the gist of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Primitive_data_type"&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.php.net/manual/en/language.types.intro.php"&gt;PHP documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Primitive"&gt;MDN&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>php</category>
      <category>javascript</category>
      <category>eli5</category>
    </item>
    <item>
      <title>Debug your Laravel Application efficiently with Laravel Telescope</title>
      <dc:creator>Célien Boillat🇨🇭</dc:creator>
      <pubDate>Wed, 03 Mar 2021 19:07:06 +0000</pubDate>
      <link>https://dev.to/celienboillat/debug-your-laravel-application-efficiently-with-laravel-telescope-290b</link>
      <guid>https://dev.to/celienboillat/debug-your-laravel-application-efficiently-with-laravel-telescope-290b</guid>
      <description>&lt;h2&gt;
  
  
  What does Telescope do?
&lt;/h2&gt;

&lt;p&gt;Laravel Telescope is an official Laravel package that's meant to help you debug a Laravel app locally.&lt;/p&gt;

&lt;p&gt;While its main use is for debugging in a local environment, it can also be used in production.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use cases
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Inspect incoming requests&lt;/li&gt;
&lt;li&gt;Inspect database queries for optimization and look out for the dreaded N+1&lt;/li&gt;
&lt;li&gt;Preview mailables locally instead of actually sending them to a third party service like &lt;a href="https://mailtrap.io/"&gt;Mailtrap.io&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Visualize dumped data without killing the page&lt;/li&gt;
&lt;li&gt;Debug caching issues&lt;/li&gt;
&lt;li&gt;View logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And much more. Take a look at the &lt;a href="https://laravel.com/docs/8.x/telescope"&gt;official documentation&lt;/a&gt; for more info.&lt;/p&gt;




&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;First, we need an existing Laravel application.&lt;br&gt;
For sake of brevity, I'm just going to provide a link to the &lt;a href="https://laravel.com/docs/8.x/installation"&gt;documentation&lt;/a&gt; instead.&lt;/p&gt;

&lt;p&gt;Telescope can be used both &lt;strong&gt;locally&lt;/strong&gt; while developing &lt;strong&gt;and in production&lt;/strong&gt;, but the steps are a little different for each use case.&lt;/p&gt;


&lt;h2&gt;
  
  
  Use Telescope locally and in production
&lt;/h2&gt;

&lt;p&gt;The installation to use Telescope both &lt;strong&gt;locally and in production&lt;/strong&gt; is the shortest one.&lt;/p&gt;

&lt;p&gt;Be warned that running Telescope in production might impact your app's performance. Disabling the watchers you don't absolutely require is advised.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;First, head to the terminal and add Telescope to the project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require laravel/telescope
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once Telescope has been successfully added to the project, publish its assets using the Artisan command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan telescope:install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! Telescope is now installed and is ready to go.&lt;/p&gt;

&lt;p&gt;In production, the number of entries saved to the database can become huge very rapidly, depending on your site's traffic. That's why you should be pruning data regularly with a scheduled Artisan command.&lt;br&gt;&lt;br&gt;
You can find out more about this subject in the official Telescope documentation.&lt;/p&gt;


&lt;h2&gt;
  
  
  Use Telescope for local development only
&lt;/h2&gt;

&lt;p&gt;Installing Telescope locally for development only is also possible if you don't need it in production.&lt;/p&gt;

&lt;p&gt;While you won't have any data for your production app, this use case has the benefit of not causing any performance hit to your app.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;As for the installation for use in production, let's head to the terminal and add Telescope to the project using Composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require laravel/telescope --dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we can publish Telescope's assets using Artisan:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan telescope:install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally run the migrations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Register the service provider manually
&lt;/h3&gt;

&lt;p&gt;Remove the Telescope service provider registration from the application's &lt;code&gt;config/app.php&lt;/code&gt; configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'providers' =&amp;gt; [
    /*
     * Application Service Providers...
     */
    // ...
    // Remove the line below
    App\Providers\TelescopeServiceProvider::class,
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is done so Laravel doesn't register Telescope when it registers its other service providers in production.&lt;/p&gt;

&lt;p&gt;Register the Telescope service provider manually in the app's &lt;code&gt;App\Providers\AppServiceProvider&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
 * Register any application services.
 *
 * @return void
 */
public function register()
{
    if ($this-&amp;gt;app-&amp;gt;environment('local')) {
        $this-&amp;gt;app-&amp;gt;register(\Laravel\Telescope\TelescopeServiceProvider::class);
        $this-&amp;gt;app-&amp;gt;register(TelescopeServiceProvider::class);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That registers the &lt;code&gt;TelescopeServiceProvider&lt;/code&gt; from the &lt;code&gt;vendor&lt;/code&gt; directory and then the one that's configured for you app.&lt;/p&gt;

&lt;p&gt;Finally, the Telescope package should not be auto-discovered by Laravel.&lt;/p&gt;

&lt;p&gt;Add Telescope's package to the &lt;code&gt;dont-discover&lt;/code&gt;array in the &lt;code&gt;composer.json&lt;/code&gt; file to ignore it when running Composer install and update commands in production:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"extra": {
    "laravel": {
        "dont-discover": [
            "laravel/telescope"
        ]
    }
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Dashboard &amp;amp; authorization
&lt;/h2&gt;

&lt;p&gt;To access Telescope's dashboard, you can visit &lt;code&gt;your-app.test/telescope&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;By default, the dashboard is only accessible in a local environment.&lt;/p&gt;

&lt;p&gt;For production environments though, you need to specify which users are allowed to access the dashboard as it is protected by an authorization gate.&lt;/p&gt;

&lt;p&gt;You can authorize users in your app's &lt;code&gt;TelescopeServiceProvider.php&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
 * Register the Telescope gate.
 *
 * This gate determines who can access Telescope in non-local  environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewTelescope', function ($user) {
        return in_array($user-&amp;gt;email, [
            // taylor@laravel.com
        ]);
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You don't need to specify any authorized user in a local environment as anyone is allowed, even unauthenticated.&lt;/p&gt;




&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;All of Telescope's configuration options can be found in its configuration file inside the app's &lt;code&gt;config&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;Be sure to review this file thoroughly to configure Telescope to your specific need.&lt;/p&gt;

&lt;p&gt;While not in the config file itself, you can toggle Telescope's dark mode in your app's TelescopeServiceProvider.php file.&lt;/p&gt;




&lt;h2&gt;
  
  
  Upgrading Telescope
&lt;/h2&gt;

&lt;p&gt;As stated in the official &lt;a href="https://laravel.com/docs/8.x/telescope#upgrading-telescope"&gt;documentation&lt;/a&gt;, you should always &lt;a href="https://github.com/laravel/telescope/blob/master/UPGRADE.md"&gt;review the changes&lt;/a&gt; when upgrading to a major version.&lt;/p&gt;

&lt;p&gt;Re-publish Telescope's assets after upgrading:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan telescope:publish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This process can also be automated by adding the last command into the post update scripts array in the &lt;code&gt;composer.json&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "scripts": {
        "post-update-cmd": [
            "@php artisan telescope:publish --ansi"
        ]
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Diving deeper
&lt;/h2&gt;

&lt;p&gt;This guide only covers installing and getting started with Laravel Telescope. There are a lot more subjects to cover like tags, watchers, etc.&lt;/p&gt;

&lt;p&gt;Be sure to always review the &lt;a href="https://laravel.com/docs/8.x/telescope"&gt;official documentation&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://laravel.com/docs/8.x/telescope"&gt;Official documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/laravel/telescope"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>php</category>
      <category>laravel</category>
      <category>telescope</category>
    </item>
  </channel>
</rss>
