30 seconds of code Short PHP code snippets for all your development needs

Overview

Logo

30 seconds of code

Short PHP code snippets for all your development needs

  • Visit our website to view our snippet collection.
  • Use the Search page to find snippets that suit your needs. You can search by name, tag, language or using a snippet's description. Just start typing a term and see what comes up.
  • Browse the PHP Snippet List to see all the snippets in this project or click individual tags at the top of the same page to narrow down your search to a specific tag.
  • Click on each snippet card to view the whole snippet, including code, explanation and examples.
  • You can use the button on the right side of a snippet card to copy the code to clipboard.
  • If you like the project, give it a star. It means a lot to the people maintaining it.

Want to contribute?

Credits & Sponsors

  • This repository is maintained by the 30-seconds organization on GitHub.
  • All snippets are licensed under the CC0-1.0 License, unless explicitly stated otherwise.
  • Logos, names and trademarks are not to be used without the explicit consent of the maintainers or owners of the 30 seconds GitHub organization.
  • Our website is powered by Netlify, Gatsby, Travis CI & GitHub.
Comments
  • [ENHANCEMENT] - Add string shorten function

    [ENHANCEMENT] - Add string shorten function

    Description

    New snippet for returning a string shortened to a given length. with ... appended by default.

    PR Type

    • [x] Snippets, Tests & Tags (new snippets, updated snippets, re-tagging of snippets, added/updated tests)
    • [ ] Tools, Scripts & Automation (anything related to files in the scripts folder, Gatsby, website, Travis CI or Netlify)
    • [ ] General, Typos, Misc. & Meta (everything related to content, typos, general stuff and meta files in the repository - e.g. the issue template)
    • [ ] Other (please specifiy in the description above)

    Guidelines

    • [x] I have read the guidelines in the CONTRIBUTING document.
    opened by StyxOfDynamite 8
  • I want to add a string shorten function.

    I want to add a string shorten function.

    Description

    I've made a simple function that shortens a string to a given length and appends an optional string to show it's been shortened.

    https://3v4l.org/II4aX

    I've got the code snippet in a .md file but don't know how to test the build process.

    https://github.com/StyxOfDynamite/30-seconds-of-php-code/blob/master/snippets/shorten.md

    opened by StyxOfDynamite 8
  • Possible integration into 30-seconds organization

    Possible integration into 30-seconds organization

    Hello, everyone! Our GitHub organization would love to have you as part of the team. You will, of course, retain all rights to your code and repository, write access and all the good stuff. The only thing that changes is that the 30-seconds team will be able to help more often with your project's needs and you will get to have access to all our communication channels.

    If you are interested, please reply with the following:

    • Main person(s) responsible for the repository after the transfer (i.e. team leaders, up to 3 people).
    • Any other people who should be part of the organization as members of the PHP team.

    If you have any questions and/or concerns, please feel free to ask me about them.

    opened by Chalarangelo 8
  • Missing unit test work after changing code snippet building process

    Missing unit test work after changing code snippet building process

    Description

    As title, since we've changed the code snippets building process, some works are missed during Travis CI build.

    As we look at the .travis.yml, it only has the code snippets building and it doesn't have any unit test works to validate these code snippet behaviors reliable and expected.

    And it also misses the section of how-to test cases writing on CONTRIBUTING.md

    IMHO, we should add this back and add contributing tips about unit test writing.

    @sohelamin, and @Chalarangelo, please concern this at your available time.

    And recommend current solution to accomplish this issue.

    Thanks :).

    enhancement 
    opened by peter279k 7
  • [FEATURE REQUEST] Adding the Date section in Table of contents

    [FEATURE REQUEST] Adding the Date section in Table of contents

    As title, I think we can consider adding the Date section to learn about simple date manipulation in 30-seconds with PHP.

    @sohelamin, what do you think about this?

    fixtures 
    opened by peter279k 5
  • Is function decapitalize correct ?

    Is function decapitalize correct ?

    function decapitalize($string, $upperRest = false) { return strtolower(substr($string, 0, 1)) . ($upperRest ? strtoupper(substr($string, 1) : substr($string, 1)); }

    function decapitalize($string, $upperRest = false) { return strtolower(substr($string, 0, 1)) . ($upperRest ? strtoupper(substr($string, 1)) : substr($string, 1)); }

    opened by Yeskendir1993 5
  • Add array collapse function

    Add array collapse function

    Adds array collapse function.

    Description

    PR Type

    • [X] Snippets, Tests & Tags (new snippets, updated snippets, re-tagging of snippets, added/updated tests)
    • [ ] Tools, Scripts & Automation (anything related to files in the scripts folder, Gatsby, website, Travis CI or Netlify)
    • [ ] General, Typos, Misc. & Meta (everything related to content, typos, general stuff and meta files in the repository - e.g. the issue template)
    • [ ] Other (please specifiy in the description above)

    Guidelines

    • [X] I have read the guidelines in the CONTRIBUTING document.
    opened by omarkdev 4
  • [NOTICE/DISCUSSION] Migration to new infrastructure

    [NOTICE/DISCUSSION] Migration to new infrastructure

    Hey there, @30-seconds/php team! How's it going?

    As you might have noticed, we are migrating repositories toa new, unified structure and template to make it easier for the core teams to maintain them. I will outline below the list of changes we are thinking of making and you can pitch in and help us (me and @fejes713) figure out the best fit and timeline for this all:

    • [ ] Update logo to match the style of the other repositories (@Chalarangelo)
    • [ ] Update snippets to the new format and match quality standards (open)
    • [ ] Remove leftover scripts, code, systems etc [1] (@fejes713)
    • [ ] Copy systems, scripts, tools from 30-seconds/30-seconds-starter and configure accordingly (@fejes713)
    • [ ] Update static parts, guidelines, issue/PR templates (@fejes713)
    • [ ] Add Google Analytics, DNS records for php.30secondsofcode.org (@Chalarangelo)
    • [ ] Rename to 30-seconds-of-php (all existing links are handled automagically by GitHub to point to the new name) (@Chalarangelo)
    • [ ] Set up Travis CI and Netlify (@Chalarangelo)

    Notes

    • [1]: If you want, you can keep parts of the existing infrastructure (e.g. a testing system or something similar), as long as you maintain them and keep them up to date and provide us with guidelines and/or help during the migration process on how to integrate them to the new template.

    Nothing is set in stone yet, but we are trying to get all repositories set up with the new template (check the 30-seconds-of-code and 30-seconds-of-python repositories to see what this looks like) and build it all up as soon as possible. However, we are asking each team to make sure there are as few issues with this as possible, so I'd love to get some feedback from you, guys. If you don't have time to participate in this procedure (which is absolutely fine), I and @fejes713 will take care of pretty much everything, so no worries, just respond below so that we know.

    enhancement 
    opened by Chalarangelo 4
  • Update Note message in README

    Update Note message in README

    As title, some messages I think we need to be changed since this repository is the part of 30-seconds organization.

    The messages are as follows:

    Note: This project is inspired by 30 Seconds of Code, but there is no affiliation with that project.
    

    This message I think should be removed/changed.

    @sohelamin, what do you think about changing this description?

    enhancement 
    opened by peter279k 4
  • Not 100% safe average example

    Not 100% safe average example

    Despite "realiness" of following example I think it'd be good if it would be mistake proof, especially when it's something for others to learn from.

    php > echo average(1,3,4,5);
    
    3.25
    
    php > echo average();
    
     
    
    Warning: Division by zero in php shell code on line 3
    
    NAN
    
    php >
    
    opened by matiit 4
  • Use 30-seconds-starter template

    Use 30-seconds-starter template

    Migration procedure to the new common template for 30 seconds repositories.

    This is still a work in progress, do not merge unless I explicitly say so!

    Tasks

    • [x] Update snippet structure to the new format
    • [x] Rename to 30-seconds-of-php
    • [x] Evaluate every snippet, check code, description, explanation, update as necessary
    • [x] Update logo to match the style of the rest of the projects
    • [x] Clean up the existing repository, remove anything not necessary
    • [x] Copy files from the starter, configure accordingly
    • [x] Update static parts, guidelines, issue/PR templates
    • [x] Update Travis, add Netlify integration
    • [x] Configure Google Analytics
    • [x] Evaluate that all scripts (extractor, builder, webber) work as planned
    • [x] Setup Netlify properly and merge, disable GitHub Pages (expect ~2 hours website downtime)
    enhancement 
    opened by Chalarangelo 3
Owner
30 seconds of code
The team behind official 30 seconds of code projects.
30 seconds of code
A PHP framework foucs on API fast development.接口,从简单开始!PhalApi简称π框架,一个轻量级PHP开源接口框架,专注于接口服务开发。

PhalApi开源接口框架 / PhalApi API Framework 读音:派框架 Stargazers over time 开发文档 / Documents 专为PHPer准备的优雅而详细的开发文档,请看:PhalApi 2.x 开发文档。 PhalApi 2.x English Docs.

dogstar 1.5k Dec 30, 2022
phpDocumentor is an application that is capable of analyzing your PHP source code and DocBlock comments to generate a complete set of API Documentation

phpDocumentor What is phpDocumentor? phpDocumentor is an application that is capable of analyzing your PHP source code and DocBlock comments to genera

phpDocumentor 3.7k Jan 3, 2023
Documentation generator for PHP Code using standard technology (SRC, DOCBLOCK, XML and XSLT)

phpDox phpDox is a documentation generator for PHP projects. This includes, but is not limited to, API documentation. The main focus is on enriching t

Arne Blankerts 588 Dec 22, 2022
Source Code for 'PHP 8 Solutions' by David Powers

Apress Source Code This repository accompanies PHP 8 Solutions by David Powers (Apress, 2022). Download the files as a zip using the green button, or

Apress 8 Oct 27, 2022
PHP 7.1 ready Smart and Simple Documentation for your PHP project

Smart and Readable Documentation for your PHP project ApiGen is the simplest, the easiest to use and the most modern api doc generator. It is all PHP

ApiGen 2.1k Dec 22, 2022
PHP 7.1 ready Smart and Simple Documentation for your PHP project

Smart and Readable Documentation for your PHP project ApiGen is the simplest, the easiest to use and the most modern api doc generator. It is all PHP

ApiGen 2.1k Apr 20, 2021
Learn how to implement the most important Design Patterns into your PHP application, uses PHP 8.1

Learn how to implement the most important Design Patterns into your PHP application. This project uses PHP 8.1. it has examples for each Pattern and an Article explaining how to use them step by step, their advantages, and disadvantages.

Gabriel Anhaia 203 Dec 15, 2022
A personal repo where I'll upload code that I write while learning laravel

Learning Laravel All of the knowledge has been gained from this Tutorial -> The best tutorial ever! Preparation Choose an IDE to code in, I personally

Lanoow 0 Oct 8, 2022
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and / or RESTful API

Luracast Restler ![Gitter](https://badges.gitter.im/Join Chat.svg) Version 3.0 Release Candidate 5 Restler is a simple and effective multi-format Web

Luracast 1.4k Jan 2, 2023
FluxBB is a fast, light, user-friendly forum application for your website.

FluxBB 1.5 Readme About FluxBB is an open source forum application released under the GNU General Public Licence. It is free to download and use and w

FluxBB 477 Dec 27, 2022
Generates documentation for your REST API from annotations

NelmioApiDocBundle The NelmioApiDocBundle bundle allows you to generate a decent documentation for your APIs. Migrate from 3.x to 4.0 To migrate from

Nelmio 2.1k Jan 6, 2023
Ladumor Laravel Swagger help to setup swagger in your application easily

Laravel Swagger Installation Install the package by the following command, composer require ladumor/laravel-swagger Add Provider Add the provider to

Shailesh Ladumor 23 Jun 17, 2022
Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations

Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations

Robert Allen 4.6k Jan 6, 2023
Documentation Generator for PHP

phpDocumentor What is phpDocumentor? phpDocumentor is an application that is capable of analyzing your PHP source code and DocBlock comments to genera

phpDocumentor 3.7k Dec 28, 2022
A php API documentation generator, fork of Sami

Doctum, a PHP API documentation generator. Fork of Sami Curious about what Doctum generates? Have a look at the MariaDB MySQL Kbs or Laravel documenta

Code LTS 203 Dec 21, 2022
Industrial-strength annotations for PHP

php-annotations Source-code annotations for PHP. Copyright (C) 2011-2015 Rasmus Schultz [email protected] https://github.com/php-annotations/php-anno

php-annotations 138 Dec 29, 2022
PHP Developer Roadmap

This is PHP Developer Roadmap

TheCodeholic 2.3k Jan 6, 2023
PhpMetrics provides metrics about PHP project and classes, with beautiful and readable HTML report.

PhpMetrics provides metrics about PHP project and classes, with beautiful and readable HTML report.

PhpMetrics 2.3k Jan 5, 2023
A boilerplate single php file for all your needs, no frameworks, no libraries.

SINGLE PHP FILE A boilerplate single php file for all your needs, no frameworks, no libraries. Avoid repetitive work It is a well known architecture d

null 15 Dec 30, 2022
STEAM education curriculum centered on building a new civilization entirely from trash, which provides all human needs for free directly to the local community

TRASH ACADEMY STEAM(Science Technology Engineering Art Math) education curriculum centered around building self-replicating technology from trash whic

Trash Robot 3 Nov 9, 2021